zoukankan      html  css  js  c++  java
  • BZOJ1709: [Usaco2007 Oct]Super Paintball超级弹珠

    n*n的范围内放m个人,主角要在某个点朝上下左右、左上右上左下右下发射子弹,求能打到所有人有几个位置。

    方法若干,总之n2过。

    ps:如果n<=10^9呢?

     1 #include<cstdio>
     2 #include<cstdlib>
     3 #include<algorithm>
     4 #include<cstdlib>
     5 #include<cstring>
     6 //#include<iostream>
     7 using namespace std;
     8 
     9 int n,m;
    10 #define maxn 111*2
    11 int row[maxn],col[maxn],a[maxn],b[maxn],mp[maxn][maxn];
    12 int x,y;
    13 int main()
    14 {
    15     scanf("%d%d",&n,&m);
    16     memset(row,0,sizeof(row));
    17     memset(col,0,sizeof(col));
    18     memset(a,0,sizeof(a));
    19     memset(b,0,sizeof(b));
    20     memset(mp,0,sizeof(mp));
    21     for (int i=1;i<=m;i++)
    22     {
    23         scanf("%d%d",&x,&y);
    24         row[x]++;
    25         col[y]++;
    26         a[n-y+x]++;
    27         b[x+y-1]++;
    28         mp[x][y]++;
    29     }
    30     int ans=0;
    31     for (int i=1;i<=n;i++)
    32         for (int j=1;j<=n;j++)
    33             if (row[i]+col[j]+a[n-j+i]+b[i+j-1]-mp[i][j]*3==m) ans++;
    34     printf("%d
    ",ans);
    35     return 0;
    36 }
    View Code
  • 相关阅读:
    AnyVal与AnyRef
    安装Zookeeper
    Kafka
    ZooKeeper总结
    Idea中JDK为1.8,还提示Diamond types are not supported at this language level
    Hive 和 Mysql
    Spark练习代码
    响应状态码
    http简介
    csrf
  • 原文地址:https://www.cnblogs.com/Blue233333/p/7154443.html
Copyright © 2011-2022 走看看