当前位置:网站首页>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;
}
边栏推荐
- Internal and external troubles of "boring ape" bayc
- Wechat official account infinite callback authorization system source code, launched in the whole network
- MPLS experiment
- Prefix and array series
- C - Inheritance - hidden method
- Cookie技术&Session技术&ServletContext对象
- navicat如何导入MySQL脚本
- MVVM of WPF
- 漏了监控:Zabbix对Eureka instance状态监控
- Introduction to the basics of network security
猜你喜欢
Path analysis model
作者已死?AI正用藝術征服人類
Introduction to ros2 installation and basic knowledge
Misc of BUU (update from time to time)
树莓派串口登录与SSH登录方法
First knowledge of OpenGL es learning (1)
C - Inheritance - polymorphism - virtual function member (lower)
漏了监控:Zabbix对Eureka instance状态监控
leetcode841. 钥匙和房间(中等)
The first Baidu push plug-in of dream weaving fully automatic collection Optimization SEO collection module
随机推荐
从autojs到冰狐智能辅助的心里历程
On the world of NDK (2)
Compile, connect -- notes-2
OpenGL ES 学习初识(1)
Introduction to the basics of network security
杰理之如若需要大包发送,需要手机端修改 MTU【篇】
Setting and using richview trvstyle template style
[server data recovery] case of offline data recovery of two hard disks of IBM server RAID5
The psychological process from autojs to ice fox intelligent assistance
Leetcode 78: subset
Missing monitoring: ZABBIX monitors the status of Eureka instance
Short video, more and more boring?
Prefix and array series
Briefly describe the differences between indexes, primary keys, unique indexes, and joint indexes in mysql, and how they affect the performance of the database (in terms of reading and writing)
Supervisor usage document
First knowledge of OpenGL es learning (1)
Project GFS data download
kubernetes集群搭建Zabbix监控平台
OpenJudge NOI 2.1 1749:数字方格
Leetcode35. search the insertion position (simple, find the insertion position, different writing methods)