카테고리 없음

[백준][Python] 14467 소가 길을 건너간 이유 1

findTheValue 2021. 9. 15. 09:43

없으면 dict에 저장. 있고 바뀌었으면 cnt+1

 

import sys
input = sys.stdin.readline

N = int(input())
state, cnt = {}, 0
for _ in range(N):
    a, b = map(int, input().split())
    if a in state and state[a] != b: cnt += 1
    state[a] = b
print(cnt)