본문 바로가기
python-algorithm

[백준] 10865

by 무적김두칠 2021. 1. 12.

1
2
3
4
5
6
7
8
9
import sys
n,m=map(int,sys.stdin.readline().split())
cnt=[0]*(n+1)
for i in range(m):
    a,b=map(int,sys.stdin.readline().split())
    cnt[a]+=1
    cnt[b]+=1
for i in range(1,n+1):
    print(cnt[i])
cs

그래프 처럼 보이는데 친구의 수만 구하면 되서 list 하나로 쉽게 구현 가능합니다.

반응형

'python-algorithm' 카테고리의 다른 글

[백준] 10874  (0) 2021.01.12
[백준] 10870  (0) 2021.01.12
[백준] 10864  (0) 2021.01.11
[백준] 10823  (0) 2021.01.11
[백준] 10822  (0) 2021.01.11

댓글