182462025-10-16 06:29:15birozsParti (75 pont)pypy3Runtime error 0/7534ms16000 KiB
N = int(input())
T = [0] * (N+1)
Volt = [False] * (N+1)
lista = []
for i in range(N):
    A,B = map(int,input().split())
    T[A] += 1
    T[B] += 1
    lista.append([A,B])
keves = []
for i in range(1,N+1):
    if T[i] < 2:
        keves.append(i)
        Volt[i] = True
while len(keves) > 0:
    akt = keves.pop()
    T[lista[akt-1][0]] -= 1
    if T[lista[akt-1][0]] < 2 and not Volt[lista[akt-1][0]]:
         keves.append(lista[akt-1][0])
         Volt[lista[akt-1][0]] = True
    T[lista[akt-1][1]] -= 1
    if T[lista[akt-1][1]] < 2 and not Volt[lista[akt-1][1]]:
         keves.append(lista[akt-1][1])
         Volt[lista[akt-1][1]] = True
db = 0
for e in Volt:
    if not e:
        db += 1
print(db-1)
if db > 0:
    for i in range(1,N+1):
        if not Volt[i]:
            print(i,end=" ")
print()
SubtaskSumTestVerdictTimeMemory
base0/75
1Runtime error0/029ms16000 KiB
2Runtime error0/028ms16000 KiB
3Runtime error0/332ms16000 KiB
4Runtime error0/330ms16000 KiB
5Runtime error0/328ms16000 KiB
6Runtime error0/332ms16000 KiB
7Runtime error0/332ms16000 KiB
8Runtime error0/432ms16000 KiB
9Runtime error0/434ms16000 KiB
10Runtime error0/432ms16000 KiB
11Runtime error0/429ms16000 KiB
12Runtime error0/428ms16000 KiB
13Runtime error0/428ms16000 KiB
14Runtime error0/430ms16000 KiB
15Runtime error0/428ms16000 KiB
16Runtime error0/430ms16000 KiB
17Runtime error0/432ms16000 KiB
18Runtime error0/432ms16000 KiB
19Runtime error0/428ms16000 KiB
20Runtime error0/430ms16000 KiB
21Runtime error0/432ms16000 KiB
22Runtime error0/432ms16000 KiB