码迷,mamicode.com
首页 > 其他好文 > 详细

bzoj 1709: [Usaco2007 Oct]Super Paintball超级弹珠【枚举】

时间:2018-05-06 18:53:53      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:AC   print   paint   getc   clu   return   algorithm   struct   iostream   

k是1e5范围的,吗?
注意到n只有100,这意味着k去重之后之后n^2,也就是1e4!
然后就可以愉快的n^4枚举了,枚举每个格子,再枚举每个敌人,如果当前格子射不到敌人则退出,否则满足所有敌人则ans++

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=105;
int n,m,tot,ans;
bool v[N][N];
struct qwe
{
    int x,y;
}a[N*N];
int read()
{
    int r=0,f=1;
    char p=getchar();
    while(p>‘9‘||p<‘0‘)
    {
        if(p==‘-‘)
            f=-1;
        p=getchar();
    }
    while(p>=‘0‘&&p<=‘9‘)
    {
        r=r*10+p-48;
        p=getchar();
    }
    return r*f;
}
int main()
{
    n=read(),m=read();
    for(int i=1;i<=m;i++)
    {
        int x=read(),y=read();
        if(!v[x][y])
            v[x][y]=1,a[++tot]=(qwe){x,y};
    }
    for(int x=1;x<=n;x++)
        for(int y=1;y<=n;y++)
        {
            int f=1;
            for(int i=1;i<=tot;i++)
            {
                int dx=abs(x-a[i].x),dy=abs(y-a[i].y);
                if(dx!=dy&&dx!=0&&dy!=0)
                {
                    f=0;
                    break;
                }
            }
            ans+=f;
        }
    printf("%d\n",ans);
    return 0;
}

bzoj 1709: [Usaco2007 Oct]Super Paintball超级弹珠【枚举】

标签:AC   print   paint   getc   clu   return   algorithm   struct   iostream   

原文地址:https://www.cnblogs.com/lokiii/p/8998965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!