题意:n*n的棋盘,现在放m个棋子,放一个棋子这一行和这一列就不会under attack了,每次放棋子回答有多少点还可能under attack;
思路:对行列进行标记。
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
__int64 a[100010],b[100010];
int main()
{
__int64 n,m,i,j,x,y,num1,num2;
while(scanf("%I64d%I64d",&n,&m)!=EOF)
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
num1=num2=0;
for(i=1;i<=m;i++)
{
scanf("%I64d%I64d",&x,&y);
if(a[x]==0)
num1++;
if(b[y]==0)
num2++;
a[x]=1;
b[y]=1;
printf("%I64d\n",(n-num1)*(n-num2));
}
}
return 0;
}