当前位置:网站首页>OpenJudge NOI 2.1 1661:Bomb Game
OpenJudge NOI 2.1 1661:Bomb Game
2022-07-06 07:14:00 【Jun Yi_ noip】
【 Topic link 】
OpenJudge NOI 2.1 1661:Bomb Game
【 Topic translation 】
subject
Bomb Game
describe
Bosko and Susko In a A That's ok B Play an interesting game on a rectangular chessboard composed of columns .
When the game starts ,Susko Put his virtual blockhouse somewhere on the chessboard , then Bosko Choose an area to throw his virtual bomb . After every explosion ,Susko Will tell Bosko Whether his bunker is in the scope of explosion .
Throw in (R, S) The explosion range of the bomb is... Side length P The square of (P It's always odd ). The center of the square is (R, S), The side of the square is parallel to the side of the chessboard , The length is P.
After some bombs have been dropped , Bosko We should find out Susko Location of the bunker , However, this position may not be the only , Your task is to help Bosko Calculate the number of possible positions .
Input
The first line contains three integers A,B, and K(1 <= A, B, K <=100.)A Indicates the number of rows ,B Represents the number of columns ,K Indicates the number of bombs thrown .
Next K The line contains integers R, S, P and T, Described in section R Xing He S Bombs dropped at the column , The diameter is P,1 <= R < = A,1 < = S < = B,1 < = P < = 99,P It's amazing Count . If the bunker is within the range of this bomb ,T be equal to 1; Otherwise 0.
Output
Output Susko The number of possible locations of blockhouses .
The sample input
5 5 3
3 3 3 1
3 4 1 0
3 4 3 1
Sample output
5
source
Croatia OI 2002 National – Juniors
【 Topic test site 】
1. enumeration
【 Their thinking 】
Enumerate all positions on the chessboard , Suppose the blockhouse exists in a position of Meiju , See if the result of bomb bombing is the same as the given result . If the result of all bombs is the same as the given result , Then the current location of the blockhouse is the location where a blockhouse may exist , Add... To the count of possible positions of blockhouses 1.
Finally, output the number of possible positions of the blockhouse .
【 Solution code 】
#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) Whether the location is within the explosion range of the bomb
{
if(abs(x - r) <= p / 2 && abs(y - s) <= p / 2)
return 1;
else
return 0;
}
};
Bomb bm[N];//bm[i]: The first i A bomb
int main()
{
int a, b, k, ans = 0;//ans: Number of possible positions
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)// Suppose the bunker is in (i,j)
{
bool isPos = true;// Is it possible that the bunker is (i,j)
for(int h = 1; h <= k; ++h)
{
if(bm[h].isCover(i, j) != bm[h].t)// If this bomb is right (i,j) The override result of is different from the preset result entered
{
isPos = false;
break;
}
}
if(isPos)
ans++;
}
cout << ans;
return 0;
}
边栏推荐
- Week6 weekly report
- Embed UE4 program into QT interface display
- 首发织梦百度推送插件全自动收录优化seo收录模块
- MPLS experiment
- Simple use of JWT
- Oracle数据库11gr2使用tde透明数据加密报错ora28353,如果运行关闭wallet会报错ora28365,运行打开wallet就报错ora28353无法打开wallet
- Top test sharing: if you want to change careers, you must consider these issues clearly!
- Chrome view page FPS
- Wechat brain competition answer applet_ Support the flow main belt with the latest question bank file
- 顶测分享:想转行,这些问题一定要考虑清楚!
猜你喜欢
随机推荐
多线程和并发编程(二)
A brief introduction of reverseme in misc in the world of attack and defense
chrome查看页面fps
LeetCode 78:子集
[server data recovery] case of offline data recovery of two hard disks of IBM server RAID5
杰理之普通透传测试---做数传搭配 APP 通信【篇】
Multi attribute object detection on rare aircraft data sets: experimental process using yolov5
Cookie技术&Session技术&ServletContext对象
The difference between get and post request types
Path analysis model
Solution to the problem of breakthrough in OWASP juice shop shooting range
C - Inheritance - polymorphism - virtual function member (lower)
How to configure GUI guide development environment
OpenJudge NOI 2.1 1661:Bomb Game
The best way to learn SEO: search engine
Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
OpenGL ES 学习初识(1)
呆错图床系统源码图片CDN加速与破解防盗链功能
Applied stochastic process 01: basic concepts of stochastic process
Raspberry pie serial port login and SSH login methods









