求这样写有什么问题,过不了test2
#include<iostream>
using namespace std;
int n, num, res = 0, x, y, xi[200010], yi[200010];
int maxx = 0;
bool exis[200010][2] = { false };
int main() {
cin >> n;
for (int i = 0;i < n;i++) {
cin >> num;
res = 0;
for (int j = 0;j < num;j++) {
cin >> x >> y;
if (x > maxx)maxx = x;
xi[j] = x;
yi[j] = y;
exis[x][y] = true;
}
for (int j = 0;j < num;j++) {
if (exis[xi[j]][0] && exis[xi[j]][1] && yi[j] == 1)res += num - 2;
if (xi[j] > 0 && xi[j] + 1 <= maxx && exis[xi[j] - 1][1 - yi[j]] && exis[xi[j] + 1][1 - yi[j]])res++;
}
printf("%d\n", res);
}
return 0;
}