当前位置:网站首页>~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)地图中某点有树,藏宝图对应位置没有树
边栏推荐
- The interviewer asked: how to prevent oversold? There are several ways to achieve it
- Floating point number exploration
- Druid 查询超时配置的探究 → DataSource 和 JdbcTemplate 的 queryTimeout 到底谁生效?
- 『每日一问』ReentrantLock加锁解锁
- ActiveMQ -- kahadb of persistent mechanism
- MySQL appends a string to the string of a field in the table [easy to understand]
- ActiveMQ -- JDBC with persistent mechanism
- What are stand-alone, cluster and distributed?
- Common tool classes under JUC package
- Difference between redis and mongodb (useful for interview)
猜你喜欢
随机推荐
『每日一问』volatile干嘛的
『每日一问』简单聊聊JMM/说说对JMM的了解
What is anemia model and congestion model?
redis的五种数据结构原理分析
将list集合的某一字段拼接单个String
【Nacos】NacosClient在服务注册时做了什么
[SCADA case] myscada helps VIB company realize the modernization and upgrading of production line
[buuctf-n1book][Chapter 2 advanced web]ssrf training
机器学习 —— Sklearn包中StandardScaler()、transform()、fit()的详细介绍
数据分析之numpy基础包
redis操作利用游标代替keys
Reverse Integer
idea中将lib目录下的jar包加入到项目中
Excl batch import data, background public parsing method
Bi business interview with data center and business intelligence (I): preparation for Industry and business research
activemq--延迟投递和定时投递
sqli-labs Basic Challenges Less1-10
[GYCTF2020]Node Game
How can technologists start their personal brand? Exclusive teaching of top five KOLs
API健康状态自检






![[buuctf-n1book][Chapter 2 advanced web]ssrf training](/img/29/8894d04b27e0e73c4458c27bd9b935.png)


