181242025-10-01 08:15:42birozsParti (75 pont)pypy3Runtime error 0/7534ms16000 KiB
N = int(input())
T = {}
Volt = {}
lista = []
for i in range(1,N+1):
    T[i] = 0
    Volt[i] = False
for i in range(N):
    A,B = map(int,input().split())
    T[A] += 1
    T[B] += 1
    lista.append([A,B])
keves = []
for k,e in T.items():
    if e < 2:
        keves.append(k)
        Volt[k] = 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.values():
    if not e:
        db += 1
print(db)
if db > 0:
    for k,e in Volt.items():
        if not e:
            print(k,end=" ")
print()
SubtaskSumTestVerdictTimeMemory
base0/75
1Runtime error0/032ms16000 KiB
2Runtime error0/028ms16000 KiB
3Runtime error0/328ms16000 KiB
4Runtime error0/332ms16000 KiB
5Runtime error0/334ms16000 KiB
6Runtime error0/332ms16000 KiB
7Runtime error0/332ms16000 KiB
8Runtime error0/429ms16000 KiB
9Runtime error0/432ms16000 KiB
10Runtime error0/430ms16000 KiB
11Runtime error0/428ms16000 KiB
12Runtime error0/432ms16000 KiB
13Runtime error0/428ms16000 KiB
14Runtime error0/432ms16000 KiB
15Runtime error0/432ms16000 KiB
16Runtime error0/432ms16000 KiB
17Runtime error0/432ms16000 KiB
18Runtime error0/427ms16000 KiB
19Runtime error0/429ms16000 KiB
20Runtime error0/430ms16000 KiB
21Runtime error0/430ms16000 KiB
22Runtime error0/427ms16000 KiB