AcWing 1788. 牛为什么过马路
输入样例:
8
3 1
3 0
6 0
2 1
4 1
3 0
4 0
3 1
 
输出样例:
3
 
 
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 15;
int a[N],sum;
int main()
{		
	int n;
	cin >> n;
	
	memset(a, -1, sizeof(a));
	while(n--)
	{
		int x,y;
		cin >> x >> y;
		
		if(a[x] == -1) a[x] = y; // 如果第一次观察,就直接赋值 
		else if(a[x] != y ) sum++, a[x] = y; // 和上一次观察得不一样,就算过马路了
	}
	cout << sum <<endl;
    return 0;
}










