44922023-03-29 10:12:30PallanekPéterParti (75 pont)python3Runtime error 0/7520ms17216 KiB
import sys
sys.setrecursionlimit(10 ** 9)
def csokken(j):
    if kihagy[j]==0:
        kihagy[j]=1
        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=[0]*N
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
base0/75
1Runtime error0/017ms11288 KiB
2Runtime error0/018ms12892 KiB
3Runtime error0/317ms11608 KiB
4Runtime error0/317ms11676 KiB
5Runtime error0/317ms12208 KiB
6Runtime error0/317ms12380 KiB
7Runtime error0/317ms12340 KiB
8Runtime error0/417ms12472 KiB
9Runtime error0/417ms12668 KiB
10Runtime error0/417ms12988 KiB
11Runtime error0/417ms12856 KiB
12Runtime error0/417ms13248 KiB
13Runtime error0/417ms13508 KiB
14Runtime error0/417ms13424 KiB
15Runtime error0/418ms14896 KiB
16Runtime error0/419ms15372 KiB
17Runtime error0/419ms15852 KiB
18Runtime error0/419ms16124 KiB
19Runtime error0/419ms16420 KiB
20Runtime error0/420ms17052 KiB
21Runtime error0/420ms17216 KiB
22Runtime error0/417ms14060 KiB