当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

Raspberry pie serial port login and SSH login methods

Multi attribute object detection on rare aircraft data sets: experimental process using yolov5

Week6 weekly report

杰理之BLE【篇】

Depth residual network

Missing monitoring: ZABBIX monitors the status of Eureka instance

Development of entity developer database application

Lesson 12 study notes 2022.02.11

leetcode841. Keys and rooms (medium)

navicat如何导入MySQL脚本
随机推荐
Twelve rules for naming variables
leetcode841. Keys and rooms (medium)
The author is dead? AI is conquering mankind with art
How to configure GUI guide development environment
JDBC learning notes
杰理之开发板上电开机,就可以手机打开 NRF 的 APP【篇】
C language_ Double create, pre insert, post insert, traverse, delete
leetcode1020. Number of enclaves (medium)
LeetCode Algorithm 2181. 合并零之间的节点
杰理之BLE【篇】
呆错图床系统源码图片CDN加速与破解防盗链功能
leetcode35. 搜索插入位置(简单,找插入位置,不同写法)
软件测试外包到底要不要去?三年真实外包感受告诉你
杰理之蓝牙设备想要发送数据给手机,需要手机先打开 notify 通道【篇】
Depth residual network
C - Inheritance - polymorphism - virtual function member (lower)
开源的网易云音乐API项目都是怎么实现的?
Bloom taxonomy
Oracle数据库11gr2使用tde透明数据加密报错ora28353,如果运行关闭wallet会报错ora28365,运行打开wallet就报错ora28353无法打开wallet
Chrome view page FPS