41632023-03-15 18:02:48kristofElágazás nélküli úton levő települések (50 pont)python3Wrong answer 2/50136ms23292 KiB
from collections import defaultdict


ki = []
n, m = list(map(int, input().split()))
graf = defaultdict(list)

#todo Is there a way without array?
arr = [0 for i in range(n)]

for i in range(m):
    honnan, hova = list(map(int, input().split()))
    graf[honnan].append(hova)
    graf[hova].append(honnan)
    arr[honnan-1] += 1
    arr[hova-1] += 1

zsakfalvak = []
zsakfalvak = [i+1 for i, value in enumerate(arr) if value == 1]

szamlalo = 0
for i in zsakfalvak:
    pass
print(szamlalo)
print(*sorted(ki))
SubtaskSumTestVerdictTimeMemory
base2/50
1Wrong answer0/020ms11796 KiB
2Wrong answer0/0134ms20888 KiB
3Wrong answer0/220ms12076 KiB
4Wrong answer0/220ms12012 KiB
5Accepted2/219ms12532 KiB
6Wrong answer0/218ms12296 KiB
7Wrong answer0/220ms12660 KiB
8Wrong answer0/228ms13548 KiB
9Wrong answer0/237ms14652 KiB
10Wrong answer0/248ms15840 KiB
11Wrong answer0/275ms17820 KiB
12Wrong answer0/275ms17896 KiB
13Wrong answer0/326ms14248 KiB
14Wrong answer0/332ms15184 KiB
15Wrong answer0/335ms15624 KiB
16Wrong answer0/335ms16356 KiB
17Wrong answer0/367ms18264 KiB
18Wrong answer0/370ms18620 KiB
19Wrong answer0/386ms19692 KiB
20Wrong answer0/3128ms22728 KiB
21Wrong answer0/3136ms23136 KiB
22Wrong answer0/3135ms23292 KiB