版本比较
Codeforces Round 1019 (Div. 2) B
正文
增加 3 行删除 3 行
40 行未改动4142434445464748495051525362 行未改动40 行未改动---**证明:**$t = 1$,则翻转对**代价**的影响非负,故取 $0$,代价为 $n$。$t = 2$,则有 $S_2 = S_1 + 1$,根据 $S$ 的定义,不难得到 $S_{[{\color{red}{S_1}} - 1, {\color{blue}{S_2}} + 1]}$ 形如 $\{a, {\color{red}{b}}, {\color{blue}{a}}, a\}$。也即 $S$ 由若干 $a$ 与 若干个连续的 $b$ 组成。$a, b \in \{\texttt{0},\ \texttt{1}\},\ a \neq b$。此时令 $l = S_1;\ r = n$ 将连续的 $b$ 翻转至 $S$ 的末尾。代价为 $n + 1$。$t = 3$,可以推出 $S$ 形如 $\{{\color{red}a, a, \dots} {\color{blue}\underline{b}, \dots b}, {\color{red}\underline{a}, \dots,} {\color{blue} \underline{b}}\}$:其中 $S$ 中的元素已用下划线标出。62 行未改动40 行未改动4142434445464748495051525362 行未改动40 行未改动---**证明:**$t = 1$,则翻转对**代价**的影响非负,故取 $0$,代价为 $n$。$t = 2$,则有 $S_2 = S_1 + 1$,根据 $S$ 的定义,不难得到 $S_{[{\color{red}{S_1}} - 1, {\color{blue}{S_2}} + 1]}$ 形如 $\{a, {\color{red}{b}}, {\color{blue}{a}}, a\}$。也即 $S$ 由若干 $a$ 与 若干个连续的 $b$ 组成。$a, b \in \{\texttt{0},\ \texttt{1}\},\ a \neq b$。此时令 $l = S_1;\ r = n$ 将连续的 $b$ 翻转至 $S$ 的末尾。代价为 $n + 1$。$t = 3$,可以推出 $S$ 形如 $\{{\color{red}a, a, \dots} {\color{blue}\underline{b}, \dots b}, {\color{red}\underline{a}, \dots,} {\color{blue} \underline{b}}\}$:其中 $S$ 中的元素已用下划线标出。62 行未改动