Last time I forgot to post. I'm sorry.
#20 Problem
** Thoughts ** Use collections because you only have to count the towns on both sides of the road
import collections
n, m = map(int,input().split())
road = []
for _ in range(m):
s = list(map(int,input().split()))
road.append(s[0])
road.append(s[1])
c = collections.Counter(road)
for i in range(1,n+1):
print(c[i])
Note that collections start at 1 unlike list
I'm sleepy so I'm going to sleep. good night
Recommended Posts