알고리즘/BOJ
[백준] 5567_결혼식
엉아_
2021. 8. 12. 01:27
728x90
N = int(input())
n = int(input())
relationship = [list(map(int,input().split())) for _ in range(n)]
people = [i for i in range(1,N+1)]
friends = []
BF= []
for i in relationship:
if 1 in i:
BF += i
for i in relationship:
for j in BF:
if j in i:
friends +=i
print(len(set(friends))-1)