181222025-10-01 08:07:29birozsParti (75 pont)python3Runtime error 44/75158ms16000 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=" ")
SubtaskSumTestVerdictTimeMemory
base44/75
1Accepted0/016ms3136 KiB
2Runtime error0/0158ms16000 KiB
3Accepted3/316ms3116 KiB
4Accepted3/316ms3128 KiB
5Wrong answer0/316ms3200 KiB
6Accepted3/317ms3080 KiB
7Accepted3/317ms3248 KiB
8Accepted4/417ms3340 KiB
9Accepted4/419ms3476 KiB
10Accepted4/424ms3592 KiB
11Accepted4/420ms3384 KiB
12Accepted4/425ms3624 KiB
13Accepted4/428ms4088 KiB
14Accepted4/435ms4172 KiB
15Runtime error0/4148ms16000 KiB
16Runtime error0/4145ms16000 KiB
17Runtime error0/4151ms16000 KiB
18Runtime error0/4145ms16000 KiB
19Runtime error0/446ms16000 KiB
20Runtime error0/450ms16000 KiB
21Runtime error0/446ms16000 KiB
22Accepted4/417ms3152 KiB