标记横纵坐标 数组标记
AC代码:
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<string>
using namespace std;
#define N 6000
#define INF 1e9+5
long long a[1000100];
long long b[1000100];
long long ans[1000100];
long long n, m, x, y;
int main()
{
long long i, j;
scanf("%I64d%I64d", &n, &m);
long long x = n, y = n;
for (i = 1; i <= m; i++)
{
long long x1, y1;
scanf("%I64d%I64d", &x1, &y1);
if (a[x1] == 0)
{
x--;
a[x1] = 1;
}
if (b[y1] == 0)
{
y--;
b[y1] = 1;
}
ans[i] = x*y;
}
for (i = 1; i <= m; i++)
{
if (i == 1) printf("%I64d", ans[i]);
else printf(" %I64d", ans[i]);
}
printf("\n");
return 0;
}