随笔分类 - 构造
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1776C "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1776/C "CF 传送门") orz p_b_p_b。 下文令 $a_i$ 为
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1844G "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1844/G "CF 传送门") 出题人脑洞真大…… 设 $x_i$ 为 $i$
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc092_c "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc092/tasks/arc092_c "AtCoder 传送门") Key obser
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/P6892 "洛谷传送门") 感觉这题递归的思想挺值得借鉴的。 特判 $n = 3$。 首先根据样例不难猜测最小次数为 $n$。事实上最小次数下界为 $n$,因为设 $x$ 为当前相邻元素相同对数,不难发现除第一次操作
阅读全文
摘要:[CF 传送门](https://codeforces.com/gym/102900/problem/B "CF 传送门") 感觉像脑筋急转弯。 考虑所有数字之和就是相邻的 $(\text{雷}, \text{空地})$ 对数,因此翻转后这个对数不会改变。 然后由于抽屉原理,$b \to a$ 和
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1364D "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1364/D "CF 传送门") 简单题。 特判掉 $m = n - 1$ 的情况
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1508D "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1508/D "CF 传送门") 先忽略掉所有 $a_i = i$ 的点。 考虑我
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc163_c "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc163/tasks/arc163_c "AtCoder 传送门") 这题是不是想到裂项
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc141_c "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc141/tasks/arc141_c "AtCoder 传送门") 考虑给出 $S$,
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF1840G2 "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1840/G2 "CF 传送门") 每次询问获得的信息只有当前所在位置的数字。考
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc146_d "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc146/tasks/arc146_d "AtCoder 传送门") 考虑直接增量构造。
阅读全文
摘要:[洛谷传送门](http://https://www.luogu.com.cn/problem/AT_arc139_c "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc139/tasks/arc139_c "AtCoder 传送门") ~~
阅读全文
摘要:洛谷传送门 注意到如果 $n$ 足够小,可以过 $n^2$。选 $x = 3$(这样做的好处是能交换两个相邻元素),每次把值为 $i$ 的元素挪到 $i$,注意到我们不关心其他元素,所以翻转 $[l, r]$ 的效果可以看成是交换 $p_l, p_r$。于是先跳大步,再跳小步。可以过 $n \le
阅读全文
摘要:洛谷传送门 AtCoder 传送门 不难猜想有解充要条件为 $n \ge 5$ 且 $\frac{n(n-1)}{2} \bmod 3 = 0$。 发现如果钦定一个点的出边都为同一种颜色,那么条件 $2$ 一定满足。 那么题目等价于把 ${0,1,...,n-1}$ 分成 $3$ 组使得每组的和相等
阅读全文
摘要:洛谷传送门 AtCoder 传送门 考虑判断有无解。把序列分成 $c = \left\lceil\frac{len}{k}\right\rceil$ 段,则 $\forall a_i \le c$ 且 $\sum\limits_{i=1}^n [a_i = c] \le ((len - 1) \bm
阅读全文
摘要:洛谷传送门 AtCoder 传送门 对每个红格的行和列连边,建出二分图。对于二分图中的每个连通块分别考虑。 大胆猜测对于每个连通块,我们都能够进行适当的操作,使得只有一行/一列没被操作(显然不能使所有行和列都被操作)。对应的方案就是随便取一棵生成树,把不被染白的那一行/列拎出来当根,然后自底向上,每
阅读全文
摘要:洛谷传送门 AtCoder 传送门 很神奇但是经典的构造,学习一下。 注意到题目给的操作很像斐波那契。但是难点是如何将 $O(\log n)$ 个斐波那契数相加。 考虑一个操作序列 $4,3,4,3,...$(共 $m$ 个)。发现在第 $i$ 个操作之前给 $x$ 或 $y$ 加 $1$,等价于最
阅读全文
摘要:洛谷传送门 AtCoder 传送门 第一步就没想到 可以考虑化简限制。设所有点按 $E_i$ 从小到大排序后顺序是 $p_1,p_2,...,p_n$。发现只需满足 $E_{p_{i+1}} - E_{p_i} \ge \operatorname{dis}(p_i, p_{i+1})$。证明是对于任
阅读全文
摘要:洛谷传送门 AtCoder 传送门 从低位往高位考虑。设当前个位为 $k$,暴力搜索这一位向上进 $i$ 位,设 $\left\lfloor\frac{n}{10}\right\rfloor - i$ 的答案为 $t$。 若 $t > 10i + k$ 显然就不可行,因为就算个位全部填 $1$ 也不
阅读全文
摘要:CF 传送门 洛谷传送门 ~~*2500 的黑(~~ 首先不考虑最小化字典序,我们发现 $res_i \ge \dfrac{2}{deg_u}$。意思是理想的状态就是在一段周期内平均分配。 这个下界是可以达到的,根据连向父亲的边的的调整连向儿子的边即可,这个构造是容易的。 于是可以发现 $res_i
阅读全文

浙公网安备 33010602011771号