# BOJ - 10159 - 저울

Updated:

```
import sys
def solution():
N = int(input())
M = int(input())
arr = [[0] * N for _ in range(N)]
for _ in range(M):
x, y = map(int, sys.stdin.readline().split())
arr[x-1][y-1] = 1
for k in range(N):
for i in range(N):
for j in range(N):
if arr[i][k] and arr[k][j]:
arr[i][j] = 1
for i in range(N):
cnt = 0
for j in range(N):
if not arr[i][j] and not arr[j][i]:
cnt += 1
print(cnt - 1)
solution()
```

https://www.acmicpc.net/problem/10159

## Leave a comment