44932023-03-29 10:14:08PallanekPéterParti (75 pont)python3Wrong answer 52/75200ms34908 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 sys.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)
    print(N-sum(kihagy))
    for i in range(N):
        if tag[i]>1:
            print(i+1, end=' ')
main()
SubtaskSumTestVerdictTimeMemory
base52/75
1Accepted0/017ms11260 KiB
2Accepted0/0166ms28340 KiB
3Accepted3/317ms11664 KiB
4Accepted3/317ms11932 KiB
5Wrong answer0/317ms12036 KiB
6Accepted3/318ms12404 KiB
7Accepted3/318ms12584 KiB
8Accepted4/418ms12708 KiB
9Accepted4/420ms13120 KiB
10Accepted4/424ms13420 KiB
11Accepted4/419ms13132 KiB
12Accepted4/425ms13532 KiB
13Accepted4/427ms14320 KiB
14Accepted4/429ms14812 KiB
15Accepted4/4170ms30052 KiB
16Accepted4/4200ms33540 KiB
17Runtime error0/4130ms34908 KiB
18Runtime error0/4128ms34672 KiB
19Runtime error0/4123ms34516 KiB
20Runtime error0/4122ms34380 KiB
21Runtime error0/4119ms34468 KiB
22Accepted4/417ms14144 KiB