Files
luogu/article/CSPS2026.md
T
hanyixuanten 8453dca92e
Check cpp / md pair / Check md headers (push) Successful in 4s
Sync solutions to Wiki / sync (push) Successful in 5s
renamed: solutions/CSPS2026.md -> article/CSPS2026.md
2026-11-03 11:17:34 +00:00

71 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CSPS 2026 游记
华二紫竹,$2026-10-31T14:30+08:00 \sim 2026-10-31T18:30+08:00$。
## timeline (git commit history):
- 14:39 init (带 diff.sh)
- 14:58 T1 45 pts
- 15:26 T1 100 pts
- 15:34 为 T1 写了 gen
- 16:04 T2 20pts(实际 36 pts)
- 16:15 T2 60 pts(实际 68 pts)
- 16:19 T2 开 long long
- 16:22 T1 对拍发现有一个变量没开 long long(感谢 diff.sh)
- 16:50 为 T2 写了 gen(然而 gen 的数据并不保证图连通 这个考场上导致好多次误判)
- 17:07 因为 T2 gen 的构造的数据问题导致不必要的 long long 和特判
- 17:59 依旧卡 T2,T3 T4 毫无推进
- (约)18:20 发现 T2 并无问题,尝试写 T3 T4 暴力,然而时间不够
## T1
最开始以为答案是关于最终相等的数单调的,想写二分,发现第二个样例证伪了这一结论。发现最终相同的数一定是 $a_i (i \in [1, n])$。
先写了个 [45pts 的暴力](https://git.vblg.top/hanyixuanten/csps2026/src/commit/bf08016dee210d518b187b7730a4f8f27ae47f24/crystal/crystal.cpp)。此时考试已开始 28 min。
考虑到使用二分 + 前缀和优化[寻找 ans 的过程](https://git.vblg.top/hanyixuanten/csps2026/src/commit/bf08016dee210d518b187b7730a4f8f27ae47f24/crystal/crystal.cpp#L12-L13)。但是因为二分出来的答案一直多 1 或少 1,就出现了[这几行代码(笑哭)](https://git.vblg.top/hanyixuanten/csps2026/src/commit/8b21377d1fa3208ef8d27b7592e91d1dbf8a40fc/crystal/crystal.cpp#L22-L23)。
然而,最开始的时候 [checkb 函数的 now 没开 long long](https://git.vblg.top/hanyixuanten/csps2026/src/commit/8b21377d1fa3208ef8d27b7592e91d1dbf8a40fc/crystal/crystal.cpp#L7),差点 100->65,diff.sh 立大功。
附 [gen.cpp](https://git.vblg.top/hanyixuanten/csps2026/src/commit/c9a42541c404d2b6395e49b9c35e4eb71109327b/crystal/gen.cpp)。
## T2
其实考试开始 34 min 就想出了[“500 条线路各视为图上的一个点,分别和地铁站连线”](https://git.vblg.top/hanyixuanten/csps2026/src/commit/64eda003fc35794e1805274785a058db89a21eeb/subway/subway.cpp#L49),但是由于无负边权,自然的想到了 dij,后续又加入了预处理优化,16:15 写完后发现并不能通过最后两个大样例(3s)。然而并没有想到 $O(n^3)$ 的 Floyd 在这种情况下更快。(写这篇记录的时候还没有正式出成绩,若 CCF 的评测机发力则可能多点分。)
附 [gen.cpp](https://git.vblg.top/hanyixuanten/csps2026/src/commit/e4991898d0b1585aa9d86a0737da057bd388de58/subway/gen.cpp)。注意这个 gen.cpp 生成的图不保证连通,所以如果代码输出了 inf 或是负数一般是图不连通导致,可忽略。
## T3 T4
由于死磕 T2 连暴力都没有写,血亏 20-60pts。
## 总结
1. 对拍、diff.sh 立大功。
2. 由于随机数只会用 time(0) 作为种子,导致对拍效率大大下降,连续拍了半个小时才发现 T1 的问题。
3. 过度的死磕 T2 导致 T3 T4 暴力没写。
4. 对算法复杂度 (dij) 有错误估测,忽视冷门算法 (Floyd),导致 T2 100 -> 68。
附 diff.sh(linux,注意对拍代码均无需开文件读写):
```sh
#!/bin/bash
g++ sol1.cpp -o sol1 -O2 -std=c++14 -static
g++ sol2.cpp -o sol2 -O2 -std=c++14 -static
g++ gen.cpp -o gen -O3 -std=c++14 -static
for i in {1..10000}; do
gen > in
sol1 < in > a
sol2 < in > b
if ! diff -q a b > /dev/null; then
echo wa
cp in wa.in
cp a wa1.out
cp b wa2.out
break
fi
echo success $i
done
```