The 2024 ICPC Asia Chengdu Regional Contest (The 3rd Universal Cup. Stage 15: Chengdu)
- The 2024 ICPC Asia Chengdu Regional Contest
- The 3rd Universal Cup. Stage 15: Chengdu
# | Problem | Coding Status | Document Status |
---|---|---|---|
A | Arrow a Row | Planned | Unavailable |
B | Athlete Welcome Ceremony | Accepted | Finished |
C | Chinese Chess | Planned | Unavailable |
D | Closest Derangement | Planned | Unavailable |
E | Disrupting Communications | Accepted | Finished |
F | Double 11 | Accepted | Planned |
G | Expanding Array | Accepted | Planned |
H | Friendship is Magic | Planned | Unavailable |
I | Good Partitions | Accepted | Planned |
J | Grand Prix of Ballance | Planned | Unavailable |
K | Magical Set | Accepted | Planned |
L | Recover Statistics | Accepted | Planned |
M | Two Convex Holes | Planned | Unavailable |
B. Athlete Welcome Ceremony
给定一个长度为 的字符串 (由 组成)。有 次询问,每次询问给出 ,要求用不超过 个 , 个 以及 个 替换 中的 ,使得字符串中相邻两个字符不同。求方案数,答案对 取模。
。
Difficulty:Easy (traditional dp, 3-dimensional prefix sum).
dp,设 表示对于字符串的前缀 ,填入了 个 , 个 ,剩余的 全替换为 且相邻字符不同的方案数。转移就是枚举下一个字符填什么,比较平凡,时间复杂度 。然后我们要求的就是:
其中 表示 字符串中 的个数。这是一个三维前缀和的形式,模拟一遍三量容斥即可,这样查询就可以 了。
时间复杂度 ,Submission。
E. Disrupting Communications
给定一个 个点的树,有 次询问,每次询问给出一个路径 ,你需要求出有多少个与 有交的连通块。答案对 取模。
。
Difficulty:Medium (tree dp).
我们不妨先钦定树以 为根,并且 ,此时如果一个连通块与 有交,那么它的根节点一定在路径 上,这是毫无疑问的。那么设 表示以 为根的连通块数量,转移是非常平凡的。那么回答询问时只需要做一遍链求和即可。
但是注意到 不一定成立,所以我们可以换根 dp,然后将询问离线,挂到路径的任一端点上即可。注意换根时可能需要除以没有逆元的数(),这也是一个常见 trick,只需要用一个结构体记录一下有多少个零因子即可。
时间复杂度 ,Submission。
F. Double 11
有一个长度为 的序列 ,你需要将其分成 个部分,令 归属部分 ,你需要为每一部分指定一个实系数 满足:
- 。
- 最小化 。
输出这个最小值即可。
。
Difficulty:Medium-Hard (dp, wqs binary search, decision monotonicity optimization methods, inequality)
先假定我们固定了序列的划分方案,专注于如何选择合适的 ,。