当前位置:网站首页>~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
边栏推荐
猜你喜欢
随机推荐
【代码源】每日一题 算的我头都大啦
Data preprocessing
kotlin基础知识点
OC -- Foundation -- dictionary
Basic network knowledge
cf #785(div2) C. Palindrome Basis
OC--Foundation--数组
Swift简单实现待办事项
[code source] daily one question three paragraph
Install MySQL in Ubuntu and create new users
微信小程序初步了解及实现底部导航栏
@3-1 CCF 2020-09-1 scale detection point query
Some operations of main function
OC--Foundation--字典
[code source] daily question simple fields and
【代码源】每日一题 分割(nlogn&n解法)
[De1CTF 2019]SSRF Me
SurfaceView 闪屏(黑一下问题)
OC -- Foundation -- Collection
The shortest path problem Bellman Ford (single source shortest path) (illustration)


![[GPLT] 2022 大众情人(floyd)](/img/30/c96306ca0a93f22598cec80edabd6b.png)





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