44402023-03-28 08:57:46PallanekPéterParti (75 pont)python3Wrong answer 52/75202ms34764 KiB
from sys import stdin, stdout
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)
    print(N-sum(kihagy))
    for i in range(N):
        if tag[i]>1:
            print(i+1, end=' ')
main()
SubtaskSumTestVerdictTimeMemory
base52/75
1Accepted0/017ms11180 KiB
2Accepted0/0165ms28436 KiB
3Accepted3/317ms11652 KiB
4Accepted3/317ms11848 KiB
5Wrong answer0/317ms12052 KiB
6Accepted3/317ms12000 KiB
7Accepted3/318ms12436 KiB
8Accepted4/418ms12240 KiB
9Accepted4/420ms13072 KiB
10Accepted4/424ms13432 KiB
11Accepted4/420ms13524 KiB
12Accepted4/424ms13808 KiB
13Accepted4/427ms14620 KiB
14Accepted4/428ms14872 KiB
15Accepted4/4164ms30616 KiB
16Accepted4/4202ms33944 KiB
17Runtime error0/4127ms34676 KiB
18Runtime error0/4125ms34588 KiB
19Runtime error0/4123ms34744 KiB
20Runtime error0/4123ms34764 KiB
21Runtime error0/4123ms34728 KiB
22Accepted4/417ms13764 KiB