44392023-03-28 08:50:51PallanekPéterParti (75 pont)python3Wrong answer 52/75210ms35104 KiB
from sys import stdin, stdout
N=int(input())
tag=[0]*N; kihagy=[0]*N;
graf=[]; db=0
def csokken(j):
    if kihagy[j]==0:
        global db
        db+=1
        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])

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-db)
    for i in range(N):
        if kihagy[i]==0:
            print(i+1, end=' ')
main()
SubtaskSumTestVerdictTimeMemory
base52/75
1Accepted0/017ms11028 KiB
2Accepted0/0178ms28404 KiB
3Accepted3/317ms11376 KiB
4Accepted3/317ms11640 KiB
5Wrong answer0/317ms12028 KiB
6Accepted3/317ms12292 KiB
7Accepted3/317ms12212 KiB
8Accepted4/418ms12284 KiB
9Accepted4/420ms12924 KiB
10Accepted4/424ms13544 KiB
11Accepted4/420ms13064 KiB
12Accepted4/424ms13824 KiB
13Accepted4/427ms14156 KiB
14Accepted4/429ms14704 KiB
15Accepted4/4172ms30056 KiB
16Accepted4/4210ms33284 KiB
17Runtime error0/4129ms35104 KiB
18Runtime error0/4130ms35068 KiB
19Runtime error0/4123ms34896 KiB
20Runtime error0/4116ms34712 KiB
21Runtime error0/4112ms34384 KiB
22Accepted4/417ms13948 KiB