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;
}
bzoj 1709: [Usaco2007 Oct]Super Paintball超级弹珠【枚举】的更多相关文章
- BZOJ 1709: [Usaco2007 Oct]Super Paintball超级弹珠
Description 奶牛们最近从著名的奶牛玩具制造商Tycow那里,买了一套仿真版彩弹游戏设备(类乎于真人版CS). Bessie把她们玩游戏草坪划成了N * N(1 <= N<= 1 ...
- 1709: [Usaco2007 Oct]Super Paintball超级弹珠
1709: [Usaco2007 Oct]Super Paintball超级弹珠 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 339 Solved: ...
- 【BZOJ】1709: [Usaco2007 Oct]Super Paintball超级弹珠
[算法]模拟 [题解]O(n^2)预处理横线(y),纵线(x),主对角线(y-x+n),副对角线(x+y). 然后n^2枚举每个点.
- BZOJ1709: [Usaco2007 Oct]Super Paintball超级弹珠
1709: [Usaco2007 Oct]Super Paintball超级弹珠 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 324 Solved: ...
- bzoj1709 [Usaco2007 Oct]Super Paintball超级弹珠 暴力
[Usaco2007 Oct]Super Paintball超级弹珠 Description 奶牛们最近从著名的奶牛玩具制造商Tycow那里,买了一套仿真版彩弹游戏设备(类乎于真人版CS). Bess ...
- [Usaco2007 Oct] Super Paintball超级弹珠
Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 489 Solved: 384[Submit][Status][Discuss] Description ...
- 【枚举】bzoj1709 [Usaco2007 Oct]Super Paintball超级弹珠
由于子弹的轨迹是可逆的,因此我们可以枚举所有敌人的位置,然后统计他们能打到的位置,这些位置也就是能打到他们的位置咯. O(n*k). #include<cstdio> using name ...
- BZOJ1709超级弹珠
1709: [Usaco2007 Oct]Super Paintball超级弹珠 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 352 Solved: ...
- BZOJ 1708: [Usaco2007 Oct]Money奶牛的硬币( dp )
背包dp.. -------------------------------------------------------------------------------- #include< ...
随机推荐
- 九度oj 题目1055:数组逆置
题目1055:数组逆置 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:8225 解决:3932 题目描述: 输入一个字符串,长度小于等于200,然后将数组逆置输出. 输入: 测试数据有多组 ...
- Win 2003 创建 IP 安全策略来屏蔽端口的图文教程
(本文用示例的方法讲解 IP 安全策略的设置方法,具体的设置还是要根据个人实际的需要来设置.另外 Windows Server 2008 与此类似.千一网络编辑注) IP安全性(Internet Pr ...
- noip模拟赛 Nephren Ruq Insania
题目背景 大样例下发链接: https://pan.baidu.com/s/1nuVpRS1 密码: sfxg 注意:本题大样例4的输出文件修改为 https://pan.baidu.com/s/1b ...
- codeforces365A
#include<stdio.h> #include<string.h>//刚做codeforces上的比赛题我都没看懂啊啊啊啊啊啊 int main() { int n,m, ...
- IOS7状态栏StatusBar官方标准适配方法
IOS7状态栏StatusBar官方标准适配方法 hello,大家好,ios7正式版已经发布,相信大家都在以各种方式来适配ios7. 如果你已经下载了xcode5,正准备使用,你会发现各种布局的改变. ...
- Delphi DBGrid实现多选
DBGrid1.Options:= DBGrid1.Options+[dgMultiSelect]; //先设置DBGrid1的多选属性为True if DBGrid1.SelectedRows.C ...
- csu1364 Interview
对拍了一波才找到的错误,此题我用的是二分答案加倍增查询,实际上query那里我觉得仍然有缺陷,因为每一次我的查找还是在循环找到一个k使得x+2^k <= y,而错的地方也正在此地,一开始没有判断 ...
- Oldboy 基于Linux的C/C++自动化开发---MYSQL
http://www.eimhe.com/forum.php?mod=viewthread&tid=142952#lastpost http://www.eimhe.com/thread-14 ...
- Orcle定时生成表数据作业
--建表 create table table41( id ) not null, --主键 col1 ), col2 ), col3 ), col4 int, col5 timestamp, col ...
- RIP
距离矢量路由协议 假设网络拓扑如下 192.168.1.0网段 - - - - R1 - - 192.168.12.0网段 - - R2 - - 192.168.23.0网段 - - R3 - - - ...