CF679E Bear and Bad Powers of 42 题意 定义一个正整数是坏的,当且仅当它是 $42$ 的次幂,否则它是好的。 给定一个长度为 $n$ 的序列 $a_i$,保证初始时所有数都是好的。 有 $q$ 次操作,每次操作有三种...
CF594E Cutting the Line 题解
CF594E Cutting the Line 做法来自 wucstdio 神仙的题解,表述经过了一定的修改,也许会好懂一些? 题意 给定一个字符串 $s$ 和一个正整数 $k$。 你可以将 $s$ 分成至多 $k$ 段,并将每一段翻转或者不翻...
Codeforces Round #623 (Div. 1, based on VK Cup 2019-2020 – Elimination Round, Engine) 题解
Codeforces Round #623 (Div. 1, based on VK Cup 2019-2020 - Elimination Round, Engine) Recommendations 用堆贪心。 const int N = 2e5 + 7; int n; ll s, ans; pair<ll, ll> p[N]; int main()...
Codeforces Round #622 (Div. 2) 题解
Codeforces Round #622 (Div. 2) Fast Food Restaurant 贪心。 inline void solve() { int a, b, c; rd(a), rd(b), rd(c); int ans = 0; if (a) ++ans, --a; if (b) ++ans, --b; ...
Lyndon 分解 学习笔记
一个很冷门的字符串算法 Lyndon 串 对于一个字符串,若其本身就是其最小后缀,则称它为 Lyndon 串。 形式化地,对于长度为 $n$ 的字符串 $s$,若满足对于 $i \in [2,n]$,都有 $s < s[i:n]$,则称其为 ...
Z 函数 学习笔记
Z 函数,又称扩展 KMP (exkmp),可以 $\mathcal O(n)$ 求出一个字符串的所有后缀与这个字符串的 LCP 长度。 定义 $z$ 函数 对于字符串 $s$,$z_i$ 定义为 $|\operatorname{LCP}(s, s[i:])|$,即从 $i$ 开始...
CF575E Spectator Riots 题解
CF575E Spectator Riots 题意 给定整点集 $\mathcal S = \{(x,y)|x,y \in [0,10^5]\}$。 给定另外 $n$ 个整点集 $\mathcal P_{1\dots n}$,对于 $i \in [1,n]$,给定 $x_i,y_i,v_i$,$\mathcal P_...
CF607E Cross Sum 题解
CF607E Cross Sum 题意 在平面直角坐标系中,给定 $n$ 条不同的直线,第 $i$ 条直线为 $y=a_i x+b_i$。 可重点集 $\mathcal I$ 为 $n$ 条直线两两的交点,可重数集 $\mathcal D$ 为 $\mathcal I$ 中所有点...
Codeforces Round #621 (Div. 1 + Div. 2) 题解
Codeforces Round #621 (Div. 1 + Div. 2) Cow and Haybales 贪心。 const int N = 107; int n, d, a[N]; inline void solve() { rd(n), rd(d); for (int i = 1; i <= n; i++) rd(a[i]); ...
CF506E Mr. Kitayuta’s Gift 题解
CF506E Mr. Kitayuta's Gift 题意 给定一个小写字符串 $s$ 和一个正整数 $n$。 要求在 $s$ 中插入恰好 $n$ 个小写字符使其回文的方案数。 $|s| \le 200$,$n \le 10^9$,答案对 $10^4 + 7$ 取模。 题解 ...