2025 CCH非专业级软件能力认证提高级第十轮总结
每日爆炸(5/1)
T3数据爆炸,std爆炸,T4数据爆炸,心态爆炸,pts爆炸
预期:100 + 100 + 看运气 + 50
实际:100 + 100 + 5 + 50
T1
题意:有一个数字 YES,否则输出 NO。
依旧先拉屎,回来再写。
发现只要记录当前可能温度最大值和最小值,如果与当前的范围不相交,就无解。否则就取个交集然后继续。
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int kMaxN = 1e5 + 5;
struct node {
int t, l, h;
} p[kMaxN];
int T, n, m;
bool cmp(node a, node b) {
return a.t < b.t;
}
void solve() {
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> p[i].t >> p[i].l >> p[i].h;
sort(p + 1, p + n + 1, cmp);
int tl = m, tr = m;
for (int i = 1; i <= n; i++) {
tl -= (p[i].t - p[i - 1].t), tr += (p[i].t - p[i - 1].t);
if (tr < p[i].l || tl > p[i].h) {
cout << "NO\n";
return;
}
tl = max(tl, p[i].l), tr = min(tr, p[i].h);
}
cout << "YES\n";
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
for (cin >> T; T; T--)
solve();
return 0;
}
又是30min,不知道为什么每一次一会T1就拉屎。
T2
题意:有一棵树,每个点上有一个数集,-1。
看到范围感觉这题是
于是就想把询问离线处理。
我们可以存下每个点的询问的
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 1e5 + 5;
struct node {
int v, id;
};
int n, fa[kMaxN], Q, ans[kMaxN], now[kMaxN];
vector<int> e[kMaxN], a[kMaxN];
vector<node> q[kMaxN];
void dfs(int x) {
vector<int> v;
for (int i = 0; i < a[x].size(); i++) {
v.push_back(now[a[x][i]]);
now[a[x][i]] = x;
}
for (int i = 0; i < q[x].size(); i++)
ans[q[x][i].id] = now[q[x][i].v];
for (int i = 0; i < e[x].size(); i++)
dfs(e[x][i]);
for (int i = 0; i < a[x].size(); i++)
now[a[x][i]] = v[i];
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 2; i <= n; i++) {
cin >> fa[i];
e[fa[i]].push_back(i);
}
for (int i = 1, k; i <= n; i++) {
for (cin >> k; k; k--) {
int x;
cin >> x;
a[i].push_back(x);
}
}
cin >> Q;
for (int i = 1; i <= Q; i++) {
int x, y;
cin >> x >> y;
q[x].push_back({y, i});
}
memset(now, -1, sizeof(now));
dfs(1);
for (int i = 1; i <= Q; i++)
cout << ans[i] << '\n';
return 0;
}
竟然有人用数剖+倍增再加线段树过了,太恐怖了。
T4
题意:有一棵以
暴力
想了1h想到了,兴奋地开始写的时候发现有
最后只能暴力遗憾离场。
T3
赛时写不动了,写完T4才来的。
后来发现是个广搜,直接死掉了。