当前位置:网站首页>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;
}
边栏推荐
- Leetcode59. spiral matrix II (medium)
- 巴比特 | 元宇宙每日必读:中国互联网企业涌入元宇宙的群像:“只有各种求生欲,没有前瞻创新的雄心”...
- Prefix and array series
- 树莓派3B更新vim
- 配置树莓派接入网络
- LeetCode Algorithm 2181. Merge nodes between zero
- 【Hot100】739. 每日温度
- Bio model realizes multi person chat
- Cookie Technology & session Technology & ServletContext object
- Arduino tutorial - Simon games
猜你喜欢

Supporting title of the book from 0 to 1: ctfer's growth road (Zhou Geng)

hydra常用命令

SSM学习

What is the biggest problem that fresh e-commerce is difficult to do now

Uncaught TypeError: Cannot red propertites of undefined(reading ‘beforeEach‘)解决方案

指尖上的 NFT|在 G2 上评价 Ambire,有机会获得限量版收藏品

idea控制台彩色日志

NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections

因高额网络费用,Arbitrum 奥德赛活动暂停,Nitro 发行迫在眉睫

MVVM of WPF
随机推荐
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
Supervisor usage document
将ue4程序嵌入qt界面显示
树莓派3B更新vim
配置树莓派接入网络
软件测试外包到底要不要去?三年真实外包感受告诉你
Top test sharing: if you want to change careers, you must consider these issues clearly!
MVVM of WPF
The differences and advantages and disadvantages between cookies, seeion and token
NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
Babbitt | metauniverse daily must read: the group image of Chinese Internet enterprises pouring into metauniverse: "there are only various survival desires, and there is no ambition for forward-lookin
Lesson 12 study notes 2022.02.11
树莓派串口登录与SSH登录方法
Arduino tutorial - Simon games
Thought map of data warehouse construction
WPF之MVVM
从autojs到冰狐智能辅助的心里历程
Wechat brain competition answer applet_ Support the flow main belt with the latest question bank file
Upgraded wechat tool applet source code for mobile phone detection - supports a variety of main traffic modes
SSM学习