当前位置:网站首页>OpenJudge NOI 2.1 1661:Bomb Game
OpenJudge NOI 2.1 1661:Bomb Game
2022-07-06 07:12:00 【君义_noip】
【题目链接】
OpenJudge NOI 2.1 1661:Bomb Game
【题目翻译】
题目
炸弹游戏
描述
Bosko和Susko在一个有A行B列组成的矩形棋盘上玩一个有趣的游戏。
当游戏开始时,Susko将他的虚拟碉堡放在棋盘的某一位置,然后Bosko选择某一区域扔他的虚拟炸弹。在每一次爆炸之后,Susko将会告诉Bosko他的碉堡是否在爆炸的范围中。
扔在(R, S)的炸弹的爆炸范围是边长为P的正方形(P总是奇数)。正方形的中心在(R, S),正方形的边与棋盘的边平行,长度为P。
在已经扔下一些炸弹之后, Bosko应该找出Susko碉堡的位置,然而这个位置可能不是唯一的,你的任务是帮助Bosko计算出可能的位置的数量。
输入
第一行包含三个整数A,B,和K(1 <= A, B, K <=100.)A表示行的数量,B表示列的数量,K表示扔炸弹的数量。
接下来的K行包含了整数R, S, P 和T,描述了在第R行和第S列处投掷的炸弹,直径为P,1 <= R < = A,1 < = S < = B,1 < = P < = 99,P为奇数。如果碉堡在这个炸弹的范围内,T等于1;否则为 0。
输出
输出Susko的碉堡可能存在的位置的数量。
样例输入
5 5 3
3 3 3 1
3 4 1 0
3 4 3 1
样例输出
5
来源
Croatia OI 2002 National – Juniors
【题目考点】
1. 枚举
【解题思路】
枚举棋盘上的所有位置,假设碉堡存在于枚举出的一个位置,看此时炸弹轰炸的结果是否与给定的结果是相同的。如果所有炸弹轰炸后的结果与给定的结果都是相同的,那么当前碉堡所在的位置就是一个碉堡可能存在的位置,碉堡可能存在的位置计数加1。
最后输出碉堡可能存在的位置数量。
【题解代码】
#include<bits/stdc++.h>
using namespace std;
#define N 105
struct Bomb
{
int r, s, p, t;
int isCover(int x, int y)//(x,y)位置是否在该炸弹的爆炸范围之内
{
if(abs(x - r) <= p / 2 && abs(y - s) <= p / 2)
return 1;
else
return 0;
}
};
Bomb bm[N];//bm[i]:第i个炸弹
int main()
{
int a, b, k, ans = 0;//ans:可能的位置数
cin >> a >> b >> k;
for(int i = 1; i <= k; ++i)
cin >> bm[i].r >> bm[i].s >> bm[i].p >> bm[i].t;
for(int i = 1; i <= a; ++i)
for(int j = 1; j <= b; ++j)//假设碉堡在(i,j)
{
bool isPos = true;//碉堡是否可能在(i,j)
for(int h = 1; h <= k; ++h)
{
if(bm[h].isCover(i, j) != bm[h].t)//如果这个炸弹对(i,j)的覆盖结果与输入的预设的结果不同
{
isPos = false;
break;
}
}
if(isPos)
ans++;
}
cout << ans;
return 0;
}
边栏推荐
- OpenGL ES 学习初识(1)
- 漏了监控:Zabbix对Eureka instance状态监控
- 【服务器数据恢复】IBM服务器raid5两块硬盘离线数据恢复案例
- How to configure GUI guide development environment
- Configure raspberry pie access network
- The best way to learn SEO: search engine
- Three methods of adding color to latex text
- Introduction to the basics of network security
- Résumé de la structure du modèle synthétisable
- UDP攻击是什么意思?UDP攻击防范措施
猜你喜欢
leetcode35. 搜索插入位置(简单,找插入位置,不同写法)
Raspberry pie serial port login and SSH login methods
UWA Pipeline 2.2.1 版本更新说明
Blue Bridge Cup zero Foundation National Championship - day 20
Week6 weekly report
leetcode1020. 飞地的数量(中等)
NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
What is the biggest problem that fresh e-commerce is difficult to do now
Wechat official account infinite callback authorization system source code, launched in the whole network
SSM learning
随机推荐
Markdown 中设置图片图注
JDBC学习笔记
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
PCL realizes frame selection and clipping point cloud
BIO模型实现多人聊天
Development of entity developer database application
The best way to learn SEO: search engine
18.多级页表与快表
19. Actual memory management of segment page combination
OpenGL ES 学习初识(1)
将ue4程序嵌入qt界面显示
leetcode704. Binary search (find an element, simple, different writing)
The first Baidu push plug-in of dream weaving fully automatic collection Optimization SEO collection module
从autojs到冰狐智能辅助的心里历程
Setting and using richview trvstyle template style
leetcode35. 搜索插入位置(简单,找插入位置,不同写法)
Entity Developer数据库应用程序的开发
leetcode59. 螺旋矩阵 II(中等)
Prefix and array series
CDN acceleration and cracking anti-theft chain function