AcWing 1788. 牛为什么过马路
原题链接
简单
#include <iostream>
#include <cstring>
#include <algorithm>
#include<vector>
using namespace std;
const int N = 105;
bool st[N];
struct {
int id;
int lu;
}a[N];
int main()
{
int t;
cin >> t;
int cnt = 0;
for (int i = 1; i <= t; i++) cin >> a[i].id >> a[i].lu;
/*int count = 0;*/
/*for (int i = 1; i <= t,count<=t; i++) {
count++;
if (st[i]==0&&st[count+i]==0 && a[i].id == a[i + count].id && ((a[i].lu & a[i + count].lu) == 0)) {
cnt++;
st[i] = true;
st[i + count] = true;
i = i + count;
}
if (i + count > t)
break;
}*/
for (int i = 1; i <= t; i++) {
for (int j = i + 1; j <= t; j++) {
if (a[i].id == a[j].id && (a[i].lu == a[j].lu)) {
j++;
break;
}
if (a[i].id == a[j].id && (a[i].lu != a[j].lu)) {
cnt++;
break;
}
}
}
cout << cnt << endl;
}