44352023-03-28 08:33:18PallanekPéterParti (75 pont)python3Time limit exceeded 47/75375ms34712 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=[]
def main():
    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)
main()
SubtaskSumTestVerdictTimeMemory
base47/75
1Accepted0/017ms11200 KiB
2Time limit exceeded0/0372ms12052 KiB
3Accepted3/317ms11712 KiB
4Accepted3/317ms11420 KiB
5Accepted3/317ms11792 KiB
6Accepted3/317ms11980 KiB
7Accepted3/318ms12228 KiB
8Accepted4/419ms12560 KiB
9Accepted4/424ms12952 KiB
10Accepted4/437ms13804 KiB
11Accepted4/424ms13416 KiB
12Accepted4/437ms13956 KiB
13Accepted4/456ms14752 KiB
14Accepted4/482ms15456 KiB
15Time limit exceeded0/4375ms14024 KiB
16Time limit exceeded0/4374ms15752 KiB
17Runtime error0/4129ms34664 KiB
18Runtime error0/4130ms34712 KiB
19Runtime error0/4128ms34480 KiB
20Runtime error0/4127ms34548 KiB
21Runtime error0/4128ms34508 KiB
22Accepted4/417ms13692 KiB