当前位置:网站首页>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;
}
边栏推荐
- Multithreading and concurrent programming (2)
- Three methods of adding color to latex text
- The difference between get and post request types
- NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
- Missing monitoring: ZABBIX monitors the status of Eureka instance
- Chrome view page FPS
- 微信脑力比拼答题小程序_支持流量主带最新题库文件
- Project GFS data download
- Establishment and operation of cloud platform open source project environment
- Top test sharing: if you want to change careers, you must consider these issues clearly!
猜你喜欢

MVVM of WPF

Week6 weekly report

CDN acceleration and cracking anti-theft chain function

树莓派3B更新vim

Oracle数据库11gr2使用tde透明数据加密报错ora28353,如果运行关闭wallet会报错ora28365,运行打开wallet就报错ora28353无法打开wallet

开源的网易云音乐API项目都是怎么实现的?

Go learning --- use reflection to judge whether the value is valid

mysql如何合并数据

You deserve this high-value open-source third-party Netease cloud music player

leetcode704. Binary search (find an element, simple, different writing)
随机推荐
UWA pipeline version 2.2.1 update instructions
Is software testing outsourcing going or not? Three years' real outsourcing experience tells you
Proteus -- Serial Communication parity flag mode
Chrome view page FPS
3. Business and load balancing of high architecture
Upgraded wechat tool applet source code for mobile phone detection - supports a variety of main traffic modes
Arduino tutorial - Simon games
Refer to how customer push e-commerce does content operation
Multi attribute object detection on rare aircraft data sets: experimental process using yolov5
Bloom taxonomy
杰理之开发板上电开机,就可以手机打开 NRF 的 APP【篇】
杰理之BLE【篇】
Résumé de la structure du modèle synthétisable
多线程和并发编程(二)
微信公众号无限回调授权系统源码 全网首发
MPLS experiment
Seriously recommend several machine learning official account
Path analysis model
C - Inheritance - hidden method
呆错图床系统源码图片CDN加速与破解防盗链功能