• 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;
    }
  • 相关阅读:
    48. Rotate Image
    47. Permutations II
    46. Permutations
    45. Jump Game II
    44. Wildcard Matching
    43. Multiply Strings
    42. Trapping Rain Water
    Python_匿名函数
    Python_内置函数之map()
    Python_面向对象_单例模式
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5802660.html
Copyright © 2020-2023  润新知