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

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;
}

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

时间: 2024-08-10 00:07:39

bzoj 1709: [Usaco2007 Oct]Super Paintball超级弹珠【枚举】的相关文章

BZOJ 1709: [Usaco2007 Oct]Super Paintball超级弹珠

题目 1709: [Usaco2007 Oct]Super Paintball超级弹珠 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 329  Solved: 255[Submit][Status] Description 奶牛们最近从著名的奶牛玩具制造商Tycow那里,买了一套仿真版彩弹游戏设备(类乎于真人版CS). Bessie把她们玩游戏草坪划成了N * N(1 <= N<= 100)单位的矩阵,同时列出了她的 K (1 <= K &l

1709: [Usaco2007 Oct]Super Paintball超级弹珠

1709: [Usaco2007 Oct]Super Paintball超级弹珠 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 339  Solved: 264[Submit][Status] Description 奶牛们最近从著名的奶牛玩具制造商Tycow那里,买了一套仿真版彩弹游戏设备(类乎于真人版CS). Bessie把她们玩游戏草坪划成了N * N(1 <= N<= 100)单位的矩阵,同时列出了她的 K (1 <= K <=

bzoj1709[Usaco2007 Oct]Super Paintball超级弹珠*

bzoj1709[Usaco2007 Oct]Super Paintball超级弹珠 题意: n*n的网格中有k头牛.在一个格子里发射子弹可以射中本格子,同行,同列,左斜线,右斜线(就是一个米字形)的牛,问能射中所有牛的格子有几个.n≤100. 题解: 枚举所有格子,从当前格子出发按题目里的方向走累计被射中的牛即可. 代码: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define

bzoj1709 [Usaco2007 Oct]Super Paintball超级弹珠 暴力

[Usaco2007 Oct]Super Paintball超级弹珠 Description 奶牛们最近从著名的奶牛玩具制造商Tycow那里,买了一套仿真版彩弹游戏设备(类乎于真人版CS). Bessie把她们玩游戏草坪划成了N * N(1 <= N<= 100)单位的矩阵,同时列出了她的 K (1 <= K <= 100,000)个对手在草地上的位置.然后她拿着这张表来找你,希望你能帮她计算一个数据. 在这个游戏中,奶牛可以用一把弹珠枪向8个方向中的任意一个射出子弹.8个方向分别

【枚举】bzoj1709 [Usaco2007 Oct]Super Paintball超级弹珠

由于子弹的轨迹是可逆的,因此我们可以枚举所有敌人的位置,然后统计他们能打到的位置,这些位置也就是能打到他们的位置咯. O(n*k). #include<cstdio> using namespace std; int n,m,a[101][101],x,y,ans; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;++i) { scanf("%d%d",&x,&y

BZOJ1709超级弹珠

1709: [Usaco2007 Oct]Super Paintball超级弹珠 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 352  Solved: 275[Submit][Status][Discuss] Description 奶牛们最近从著名的奶牛玩具制造商Tycow那里,买了一套仿真版彩弹游戏设备(类乎于真人版CS). Bessie把她们玩游戏草坪划成了N * N(1 <= N<= 100)单位的矩阵,同时列出了她的 K (1 <

BZOJ 1644: [Usaco2007 Oct]Obstacle Course 障碍训练课

题目 1644: [Usaco2007 Oct]Obstacle Course 障碍训练课 Time Limit: 5 Sec  Memory Limit: 64 MB Description 考虑一个 N x N (1 <= N <= 100)的有1个个方格组成的正方形牧场.有些方格是奶牛们不能踏上的,它们被标记为了'x'.例如下图: . . B x .. x x A .. . . x .. x . . .. . x . . 贝茜发现自己恰好在点A处,她想去B处的盐块舔盐.缓慢而且笨拙的动物

BZOJ 1644: [Usaco2007 Oct]Obstacle Course 障碍训练课( BFS )

BFS... 我连水题都不会写了QAQ ------------------------------------------------------------------------- #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<queue> #define rep( i , n ) for( int i = 0 ; i &

BZOJ 1708: [Usaco2007 Oct]Money奶牛的硬币( dp )

背包dp.. -------------------------------------------------------------------------------- #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #define rep( i , n ) for( int i = 0 ; i < n ; ++i ) #define clr( x