choideu 2021. 10. 3. 01:57

백준 14467 - 소가 길을 건너간 이유

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

 

14467번: 소가 길을 건너간 이유 1

3번 소는 위치 1, 0, 1에서 관찰되었으므로 길을 최소 두 번 건넜음을 확인할 수 있다. 4번 소도 길을 한 번 건넜으며, 나머지 소는 길을 건넌 기록이 확인되지 않는다.

www.acmicpc.net

n = int(input())

start = [0] * 11
pos = [0] * 11
count = 0

for i in range(n):
    num, left_right = map(int, input().split())
    if start[num] == 1:
        if pos[num] != left_right:
            count += 1
            pos[num] = left_right
    else:
        start[num] = 1
        pos[num] = left_right

print(count)