LoginSignup
1
3

More than 3 years have passed since last update.

はじめに

前回
投稿忘れてました。すみません。

#20

問題

考えたこと
道の両辺の町をカウントすればいいので、collectionsを使う

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])

collectionsはlistと違って1から始まることに注意

まとめ

ねむいので寝ます。おやすみなさい

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3