当前位置:网站首页>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;
}
边栏推荐
- leetcode59. 螺旋矩阵 II(中等)
- 接口自动化测试框架:Pytest+Allure+Excel
- navicat如何导入MySQL脚本
- Refer to how customer push e-commerce does content operation
- JDBC learning notes
- 1091: two or three things in childhood (multi instance test)
- 编译,连接 -- 笔记 -2
- ORACLE列转行--某字段按指定分隔符转多行
- Simple use of JWT
- Interface automation test framework: pytest+allure+excel
猜你喜欢
随机推荐
Thought map of data warehouse construction
Multithreading and concurrent programming (2)
MVVM of WPF
Yield method of tread
OpenJudge NOI 2.1 1749:数字方格
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
OpenGL ES 学习初识(1)
The differences and advantages and disadvantages between cookies, seeion and token
How are the open source Netease cloud music API projects implemented?
UWA Pipeline 2.2.1 版本更新说明
Due to high network costs, arbitrum Odyssey activities are suspended, and nitro release is imminent
Librosa audio processing tutorial
Kubernetes cluster builds ZABBIX monitoring platform
升级版手机检测微信工具小程序源码-支持多种流量主模式
supervisor 使用文档
Arduino tutorial - Simon games
leetcode841. 钥匙和房间(中等)
杰理之如若需要大包发送,需要手机端修改 MTU【篇】
这个高颜值的开源第三方网易云音乐播放器你值得拥有
PCL realizes frame selection and clipping point cloud









