CSP-S2024 邮寄
Day -1
我是菜狗,莫名分到十六中考试。
Day 0 Morning
进行了思想上激烈的斗争,并写了一半的权值线段树。
Day 0 Afternoon
考场扶手刚刷过油漆,好难闻。
逆天考场,四人一桌,隔板隔了和隔了似的,一碰就倒。
更神奇的来了,考试压缩包损坏无法打开,传奇啊,开考一分多钟才解决。
终于输对密码了,开始写题。
T1
一眼诈骗题,桶排秒了。
貌似有个结论,也就那样,于是就没管。
Code
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, a[100001], s, t[100001], mx, ans;
signed main() {
cin.tie(0)->sync_with_stdio(false);
// freopen("duel.in", "r", stdin);
// freopen("duel.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i], t[a[i]]++, mx = max(mx, a[i]); s = t[1];
for (int i = 2; i <= mx; i++)
ans += min(s, t[i]), s = max(0ll, s - t[i]), s += t[i];
cout << n - ans;
return 0;
}
T2
第一眼感觉不对,这题好像有点简单。
哦原来最南端不是一起出发的,我还以为结论题。
第二眼:那这题不还是有点简单吗???
于是开始考虑第一问,花了 20min 写完了。
第二问 10min 结束,开始调。
我这调的磨磨蹭蹭的,第一个样例好不容易过了,一看时间 4:30。
开始弄大样例,然后笑容消失了,因为总共就错了一个数,心态真崩了,而且都是
又开始瞎调试。
5:30 了,我心想不能再颓废了,于是先写 T3 去了。
5:45 回来调大样例,我突然发现这大样例原来是特殊性质哦,于是花了 5min 调过错的数据点。
6:15 检查,发现其他样例错了,花了 5min 调对了。
Code
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, m, L, V, s[1000002], mx[1000002];
double d[100001], v[100001], a[100001];
vector<pair<int, int > > p;
void solve() {
cin >> n >> m >> L >> V;
memset(s, 0, sizeof(s)); memset(mx, -1, sizeof(mx)); p.clear();
for (int i = 1; i <= n; i++)
cin >> d[i] >> v[i] >> a[i];
for (int i = 1, b; i <= m; i++)
cin >> b, s[b]++, mx[b] = b;
for (int i = 0; i <= L; i++)
s[i] += s[i - 1], mx[i] = max(mx[i - 1], mx[i]);
for (int i = 1; i <= n; i++)
if (v[i] <= V) {
if (a[i] > 0) {
ll dis = floor(((ll)V * V - v[i] * v[i]) / (2 * a[i])), l = min((ll)d[i] + dis + 1, (ll)L + 1);
if (l <= L && s[L] - s[l - 1])
p.push_back({L, l});
}
} else {
if (a[i] >= 0) {
if (d[i] <= L && s[L] - s[(int)d[i] - 1])
p.push_back({L, d[i]});
} else {
ll dis = ceil(((ll)V * V - v[i] * v[i]) / (2 * a[i])), r = min((ll)d[i] + dis - 1, (ll)L);
if (d[i] <= r && s[r] - s[(int)d[i] - 1])
p.push_back({r, d[i]});
}
} cout << p.size() << ' ';
sort(p.begin(), p.end()); int pre = -1, cnt = 0;
for (auto u : p)
if (pre < u.second)
cnt++, pre = mx[u.first]; cout << m - cnt << '\n';
}
int main() {
cin.tie(0)->sync_with_stdio(false);
// freopen("detect.in", "r", stdin);
// freopen("detect.out", "w", stdout);
int t; cin >> t;
while (t--) solve();
return 0;
}
T3
开题的时候就剩一个小时了。
先把容易统计的答案缩了,于是开始考虑剩下的部分。
然后随便口胡了一个线性做法,莫名差了一个数据。
发现数组没清空,笑。5min 调过。
赛后发现提交的时候丢了一个
Code
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, t[1000001], suf[200001], f[200001]; vector<int > a;
void solve() {
cin >> n; a.clear(); a.push_back(0);
memset(t, 0, sizeof(t));
memset(suf, 0, sizeof(suf));
memset(f, 0, sizeof(f));
int ans = 0;
for (int i = 1, v; i <= n; i++) {
cin >> v;
if (!a.size() || v != a.back())
a.push_back(v);
else
ans += v;
} n = a.size() - 1;
for (int i = 1; i <= n; t[a[i]] = i, i++)
if (t[a[i]])
suf[t[a[i]]] = i;
for (int i = n; i; i--)
if (suf[i])
f[i] = max(f[i + 1], f[suf[i] - 1] + a[i]);
else
f[i] = f[i + 1];
cout << ans + f[1] << '\n';
}
signed main() {
cin.tie(0)->sync_with_stdio(false);
// freopen("color.in", "r", stdin);
// freopen("color.out", "w", stdout);
int t; cin >> t;
while (t--) solve();
return 0;
}
T4
史。没看懂。
Day 0 Evening
非常兴奋,去吃了烧烤,好吃。
写了 T3 题解,也是口胡一波呀。
Day 1
拿到自己的代码,开测。
T3 莫名其妙挂分了,才发现
T2 比考场机子快了
然后语文莫名作文考了