44322023-03-28 08:24:41PallanekPéterParti (75 pont)python3Time limit exceeded 47/75372ms34788 KiB
from sys import stdin, stdout
def csokken(j):
    if j not in kihagy:
        kihagy.append(j)
        tag[graf[j][0]]-=1
        tag[graf[j][1]]-=1
        if tag[graf[j][0]]<2:
            csokken(graf[j][0])
        if tag[graf[j][1]]<2:
            csokken(graf[j][1])
    return

N=int(input())
tag=[0]*N; kihagy=[]
graf=[]
for i in range(N):
    a,b=[int(i) for i in stdin.readline().split()]
    graf.append([a-1,b-1])
    tag[a-1]+=1; tag[b-1]+=1
for i in range(N):
    if tag[i]<2:
        csokken(i)
ki=[]
for i in range(N):
    if tag[i]>1:
        ki.append(i+1)
print(len(ki))
print(*ki)
        
SubtaskSumTestVerdictTimeMemory
base47/75
1Accepted0/017ms11036 KiB
2Time limit exceeded0/0372ms12108 KiB
3Accepted3/317ms11560 KiB
4Accepted3/317ms11724 KiB
5Accepted3/317ms11924 KiB
6Accepted3/317ms12228 KiB
7Accepted3/317ms12192 KiB
8Accepted4/420ms12628 KiB
9Accepted4/424ms13236 KiB
10Accepted4/439ms13784 KiB
11Accepted4/424ms13416 KiB
12Accepted4/439ms14112 KiB
13Accepted4/457ms14844 KiB
14Accepted4/482ms15156 KiB
15Time limit exceeded0/4368ms14072 KiB
16Time limit exceeded0/4370ms15768 KiB
17Runtime error0/4138ms34788 KiB
18Runtime error0/4144ms34648 KiB
19Runtime error0/4136ms34760 KiB
20Runtime error0/4136ms34700 KiB
21Runtime error0/4142ms34580 KiB
22Accepted4/417ms13992 KiB