当前位置:网站首页>~1 CCF 2022-06-2 treasure hunt! Big adventure!
~1 CCF 2022-06-2 treasure hunt! Big adventure!
2022-07-25 09:39:00 【Ye Xiaobai】
Treasure hunt ! Great adventure !
Title Description

Input

Output

The sample input
Example 1 :
5 100 2
0 0
1 1
2 2
3 3
4 4
0 0 1
0 1 0
1 0 0
Example 2 :
5 4 2
0 0
1 1
2 2
3 3
4 4
0 0 0
0 1 0
1 0 0
Sample output
Example 1 :
3
Example 2 :
0
The subtasks

Source code
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main() {
int n, L, s;
cin >> n >> L >> s;
vector<pair<int, int>> v(n);
set<pair<int, int>> set;
for (int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
set.insert(v[i]);
}
vector<vector<int>> f(s + 1, vector<int>(s + 1));
for (int i = s; i >= 0; i--) {
for (int j = 0; j <= s; j++) {
cin >> f[i][j];
}
}
int ret = 0;
for (int i = 0; i < n; i++) {
int r = v[i].first;
int c = v[i].second;
bool check = true;
// If the matrix starting at the current point is not enough to contain the entire treasure map
if (r + s > L || c + s > L)
check = false;
for (int j = r, tr = 0; j <= r + s && check && tr <= s; j++, tr++) {
for (int k = c, tc = 0; k <= c + s && check && tc <= s; k++, tc++) {
if (f[tr][tc]) {
if (set.find({
j, k}) == set.end()) {
check = false;
}
} else {
if (set.find({
j, k}) != set.end()) {
check = false;
}
}
}
}
if (check)
ret++;
}
cout << ret;
return 0;
}
About this problem
1. Note the subscript of the matrix , Not in order .
2. When code is submitted , choice CPP11 or CPP14
3. The current point cannot correspond to the lower left corner of the treasure map in three cases :
(1) The matrix starting at the current point is not enough to contain the entire treasure map
(2) There is a tree somewhere in the treasure map , There is no tree in the corresponding position in the map
(3) There are trees at some point in the map , There is no tree in the corresponding position of the treasure map
边栏推荐
猜你喜欢
随机推荐
[code source] daily question tree
Operation 7.19 sequence table
OC--Foundation--数组
微信小程序实现轮播图(自动切换&手动切换)
Stm32+hc05 serial port Bluetooth design simple Bluetooth speaker
[code source] daily question farmland Division
学习 Redis linux 安装Redis
OC--对象复制
浏览器访问swagger失败,显示错误ERR_UNSAFE_PORT
基于机智云平台的温湿度和光照强度获取
打造个人极限写作流程 -转载
深入解读C语言随机数函数和如何实现随机数
The jar package has been launched on Alibaba cloud server and the security group has been opened, but postman still can't run. What should we do
[code source] a prime number of fun every day (BFS)
How to configure SSH after changing the computer
[De1CTF 2019]SSRF Me
How many regions can a positive odd polygon be divided into
初识Opencv4.X----方框滤波
@1-1 CCF 2021-04-1 灰度直方图
UI——无限轮播图和分栏控制器






![[code source] daily question - queue](/img/79/79570529445e7fbb86fb63af8dcf50.jpg)


