알고리즘

[알고리즘] 백준 14467 - 소가 길을 건너간 이유 1 (C++)

blueberrysoda 2024. 10. 9. 23:52

[문제 링크] : https://www.acmicpc.net/problem/14467

#include <iostream>
#include <cstring>
using namespace std;

int Arr[11];
int N;

int main(){
    memset(Arr,-1,sizeof(Arr));
    cin >> N;

    int Ans = 0;

    while(N--){
        int a, b;
        cin >> a >> b;
        if(Arr[a] != -1 && Arr[a] != b){
            Ans++;
        }
        Arr[a] = b;
    }
    cout << Ans << "\n";
    return 0;
}