随笔分类 - 做题记录
摘要:洛谷传送门 AtCoder 传送门 人生中第一道 AtCoder 问号题。 设 \(P = 998244353\)。 注意到 \(f(T)\) 的定义式中,\(\frac{1}{n}\) 大概是启示我们转成概率去做。发现若把 \(\frac{1}{n}\) 换成 \(\frac{1}{n - 1}\
阅读全文
摘要:洛谷传送门 CF 传送门 区间显然不好处理,考虑转化成前缀和后缀。 设 \(f'_i\) 为 \(T[1 : i]\) 的单词出现次数,\(f_i\) 为 \(f'_i\) 的前缀和,\(g_i\) 为 \(T[1 : i]\) 后缀最长的单词编号。都可以通过建 \(s_i\) 正串的 ACAM 预
阅读全文
摘要:洛谷传送门 CF 传送门 典? 考虑枚举 \(r\),算有多少种方案使得,存在一个点,离它最近的黑点距离 \(> r\)。 设 \(f_{u, i}\) 为 \(u\) 子树内离 \(u\) 最近的黑点距离为 \(i\)。如果一个点子树中离它最近的黑点距离 \(> r\),那么它就已经满足子树的限制
阅读全文
摘要:洛谷传送门 LOJ 传送门 很妙的题。但是我今天才补/ll 发现苹果生长的间隔是定值,也就是说,第 \(i\) 个人在某个时刻摘了一棵树上的苹果,那么下一个摘到这个苹果的人确定。设其为 \(p_i\),连边 \(i \to p_i\),就构成了一个内向基环森林。还可以顺便给这条边赋一个边权,意义是这
阅读全文
摘要:洛谷传送门 CF 传送门 首先转化一下,让鸭子不动,猎人往右移动,就相当于开的相邻两枪距离 \(> m\)。 设 \(f_{x, i}\) 为仅考虑 \(r \le x\) 的鸭子,上一次在 \(i\) 开枪,能打到的最大鸭子个数。 \(f_{x - 1} \to f_x\) 时,首先有 \(f_{
阅读全文
摘要:洛谷传送门 LOJ 传送门 为了方便,设 \(a_0 = a_{n + 1} = \infty\)。 考虑拎出来所有区间 \([l, r]\) 使得 \(\sum\limits_{i = l}^r a_i < \min(a_{l - 1}, a_{r + 1})\)。那么 \([l, r]\) 中的
阅读全文
摘要:洛谷传送门 无聊的水题。 根据裴蜀定理,显然能组合出任意值的充要条件是,选出的数的 \(\gcd = 1\)。 设 \(g(i)\) 为在 \(1 \sim n\) 中选出若干个数使得它们 \(\gcd = i\) 的方案数,\(f(i)\) 为在 \(1 \sim n\) 中选出若干个数使得它们
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/P9520 "洛谷传送门") [LOJ 传送门](https://loj.ac/p/3685 "LOJ 传送门") 观察可得,若存在合法解,则一定存在一种解,使得每个人都不停顿地从起点走到终点。 因为如果一个人走到一半
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/P9528 "洛谷传送门") [LOJ 传送门](https://loj.ac/p/3693 "LOJ 传送门") [UOJ 传送门](https://uoj.ac/problem/730 "UOJ 传送门") 神题。
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_agc041_f "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/agc041/tasks/agc041_f "AtCoder 传送门") 神题!!!!!!!
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF960G "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/960/G "CF 传送门") 发现设排列最大值位置为 $i$,那么 $[1, i]
阅读全文
摘要:[QOJ 传送门](https://qoj.ac/problem/149 "QOJ 传送门") 好题,但是也是经典题。 考虑有一个显然的 dp,$f_i$ 表示杀掉前 $i$ 只甲虫的最小代价,那么: $$f_i = \min\limits_{j = i - m}^{i - 1} (f_j + \m
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/P5068 "洛谷传送门") 这题 $O(n)$ 个人中有 $O(\frac{n}{\ln n})$ 种做法。 我们考虑 $L = R$ 怎么做。设 $p = L = R$,等价于找到一个最大的正整数 $k$,使得没有
阅读全文
摘要:[UOJ 传送门](https://uoj.ac/problem/33 "UOJ 传送门") 设 $f_{u, i}$ 为 $u$ 子树内深度为 $i$ 的点的个数,在 $\operatorname{LCA}$ 处计算答案。但是时间复杂度无法接受。 考虑长剖,计算答案只用枚举到轻链长,先对轻儿子做一
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1864F "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1864/F "CF 传送门") 感觉 $\text{F x$ 时答案就不用 $+
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1864E "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1864/E "CF 传送门") 感觉是很费脑子的题,可能是因为我没有脑子。 因为
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1864D "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1864/D "CF 传送门") 拆题中式子的绝对值,得: - $x - y \g
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc317_g "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc317/tasks/abc317_g "AtCoder 传送门") 考虑转化成匹配问题
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF825G "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/825/G "CF 传送门") 模拟赛赛时做法。 看到查询路径点权最小值,想到建重构
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1860D "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1860/D "CF 传送门") 首先考虑一个子问题,给两个只含有 $0$ 和 $
阅读全文

浙公网安备 33010602011771号