2025/7/21 集训总结
幻丶影
·
·
生活·游记
```cpp
#include <bits/stdc++.h>
using namespace std;
int main(){
int z0,h,u0,v0,u1,v1,q;
cin >> z0 >> h >> u0 >> v0 >> u1 >> v1 >> q;
while (q--){
int xi,yi,zi;
cin >> xi >> yi >> zi;
if (min(u0,u1) <= xi && xi <= max(u0,u1) && min(v0,v1) <= yi && yi <= max(v0,v1) &&
z0 <= zi && zi <= z0 + h)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
```
随后吃了两发 $B$ 题罚时,当时感觉这题不可做,转战 $C$ 题,也是一个需要读懂题目的题,意思就是找到 $n\times m$ 个字符串中不同的那个的位置,但是数据并没有把字符串分隔,所以此题还考察字符串处理能力,$90min$ 时过了。
```cpp
#include <bits/stdc++.h>
using namespace std;
string s[210];
unordered_set<string> ust;
int main(){
int n,m,k;
cin >> n >> m >> k;
for (int i = 0;i < n;i++)
cin >> s[i];
string r;
for (int i = 0;i < n;i++)
for (int j = 0;j < m;j++){
if (ust.count(s[i].substr(j * k,k)))
r = s[i].substr(j * k,k);
ust.emplace(s[i].substr(j * k,k));
}
for (int i = 0;i < n;i++)
for (int j = 0;j < m;j++)
if (r != s[i].substr(j * k,k)){
cout << i + 1 << ' ' << j + 1 << endl;
return 0;
}
return 0;
}
```
接下来看到过 $E$ 题的人很多于是我也开始做,这题也考察字符串处理能力,同时还考察字符串匹配,可以用 STL 或哈希表,特别注意的是如果一篇文章中有多个不会的单词只用查一次字典,为此我还怒开了两个`unordered_set`,$105min$ 时过了这题。
```cpp
#include <bits/stdc++.h>
using namespace std;
int main(){
unordered_set<string> ust1;
do{
string s;
cin >> s;
if (!isalpha(s.back()))
s.pop_back();
for (char &i : s)
i = tolower(i);
ust1.emplace(s);
}while (getchar() != '\n');
int n;
cin >> n;
unordered_set<string> ust2;
while (n--){
string s;
cin >> s;
ust2.emplace(s);
}
int ans = 0;
for (string i : ust1)
ans += !ust2.count(i);
cout << ans << endl;
return 0;
}
```
然后又开始看 $B$ 题,直到 $12:00$ 还是没看出啥,遂去吃午饭。下午 $2:00$ 继续考试,又想到字符串最多变化 $6$ 次于是又写了一份代码但还是没过……检查时突然发现字符串变化的方向搞错了,赶紧调过来,$50min$ 时通过。
```cpp
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while (t--){
int n,k;
string s;
cin >> n >> k >> s;
if (n < 7){
cout << 0 << endl;
continue;
}
int ans = 0;
for (int i = 0;i <= min(k,7);i++){
int num = 0;
for (int j = 0;j < n - 6;j++)
num += s.substr(j,7) == "nanjing";
ans = max(ans,num);
s += s.front();
s.erase(s.begin());
}
cout << ans << endl;
}
return 0;
}
```
然后做 $D$ 题,看了半天没啥思路,只想到了可以先通过按🗿的👃把所有🗿转到同一个方向,再按自己的👃把所有🗿转到朝前。
发现 $H$ 题过的人比较多开始做起了 $H$,$H$ 纯一大%拟,代码写得很快但是调的时候很痛苦,比赛就结束了都没调出来。
感想:$H$ 题没开 long long,我也是很成功地和太爷爷碰面了好吧。