当前位置:网站首页>~1 ccf 2022-06-2 寻宝!大冒险!
~1 ccf 2022-06-2 寻宝!大冒险!
2022-07-25 09:19:00 【叶萧白】
题目描述

输入

输出

样例输入
样例一:
5 100 2
0 0
1 1
2 2
3 3
4 4
0 0 1
0 1 0
1 0 0
样例二:
5 4 2
0 0
1 1
2 2
3 3
4 4
0 0 0
0 1 0
1 0 0
样例输出
样例一:
3
样例二:
0
子任务

源代码
#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 (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;
}
关于这题
1.注意矩阵的下标,不是按着顺序来的。
2.提交代码时,选择CPP11或CPP14
3.当前点不能与藏宝图左下角对应分三种情况:
(1)当前点开始的矩阵不足以包含整个藏宝图
(2)藏宝图中某点有树,地图中对应位置没有树
(3)地图中某点有树,藏宝图对应位置没有树
边栏推荐
猜你喜欢
随机推荐
抽象类和接口的区别(最详细)
Redis的十大常见应用场景
分享一个避免递归的部门设计方法
The interviewer asked: how to prevent oversold? There are several ways to achieve it
BigDecimal 对数据进行四舍五入
mysql中的数据结果排名
[De1CTF 2019]SSRF Me
sqli-labs安装 环境:ubuntu18 php7
Deep understanding of static keyword
保姆级Scanner类使用详解
Ranking of data results in MySQL
redis的五种数据结构原理分析
Redis数据库基础
&lt; T&gt; Generic method demonstration
什么是贫血模型和充血模型?
MySQL排序
Two Sum
Analysis of five data structure principles of redis
Activemq-- delayed delivery and scheduled delivery
Mongodb exploration phase [easy to understand]
![[arm] Xintang nuc977 transplants wk2124 drive](/img/0c/fa21d7a44e0263dde4d3135a78818f.png)
![[C language] dynamic memory management, flexible array](/img/da/b9455885df0cb6646908e3655d62c5.png)




![[HCTF 2018]admin](/img/d7/f0155c72d3fbddf0a8c1796a179a0f.png)

![[GYCTF2020]Ez_Express](/img/ce/02b90708f215715bb53cacfd4c21f0.png)
