棋盘(简单模拟)

没有什么好说的,只要注意一下 “%lld” 。

#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 100;
ll n,m,Tot,Rx,Ly;
int Row[MAXN],Lin[MAXN];
int main() {
    freopen("chess.in","r",stdin);
    freopen("chess.out","w",stdout);
    scanf("%lld%lld",&n,&m);
    Tot = n * n;
    for(int i = 1; i<=m; i++) {
        int x,y;
        scanf("%d%d",&x,&y);
        ll Tmp;
        if(!Row[x] && !Lin[y]) {
            Row[x] = Lin[y] = 1;
            Tmp = n * 2 - 1 - Rx - Ly;
            Tot -= Tmp;
            Rx ++;
            Ly ++;
        } else if(!Row[x]) {
            Row[x] = 1;
            Tmp = n - 1 - Ly + 1;
            Tot -= Tmp;
            Rx ++;
        } else if(!Lin[y]) {
            Lin[y] = 1;
            Tmp = n - 1 - Rx + 1;
            Tot -= Tmp;
            Ly ++;
        }
        printf("%lld\n",Tot);
    }
    return 0;
}
posted @ 2018-04-07 15:04  WenOI  阅读(696)  评论(0编辑  收藏  举报
水波背景