zoukankan      html  css  js  c++  java
  • CodeForces 701B Cells Not Under Attack

    统计一下有多少行多少列被占领了。

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<stack>
    #include<iostream>
    using namespace std;
    typedef long long LL;
    const double pi=acos(-1.0),eps=1e-8;
    void File()
    {
        freopen("D:\in.txt","r",stdin);
        freopen("D:\out.txt","w",stdout);
    }
    template <class T>
    inline void read(T &x)
    {
        char c = getchar(); x = 0;while(!isdigit(c)) c = getchar();
        while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar();  }
    }
    
    const int maxn=100010;
    int n,m,r[maxn],c[maxn];
    LL sumr,sumc;
    
    int main()
    {
        scanf("%d%d",&n,&m);
        LL ans=(LL)n*(LL)n;
        for(int i=1;i<=m;i++)
        {
            int x,y; scanf("%d%d",&x,&y);
            if(r[x]==0) r[x]=1,sumr++;
            if(c[y]==0) c[y]=1,sumc++;
            printf("%lld ",ans-(LL)n*(sumr+sumc)+sumr*sumc);
        }
        return 0;
    }
  • 相关阅读:
    继承
    对象和封装
    类的无参、带参方法
    类和对象
    数组
    循环结构
    选择结构
    变量、数据类型和运算符
    快捷键
    MyEclipse与JDK的配置
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5802660.html
Copyright © 2011-2022 走看看