codeforces round 872 a-d

Codeforces Educational Round 153

# Codeforces Educational Round 153 ### T1,T2,T3 比较简单的题目。 ### T4 首先存在一个观点:一个位置至多只会被交换一次。因为交换两次的情况可以被某一种交换一次的方案替代。比如 $101$ 进行 $(1,2),(1,3)$ 两次交换 得到序列 $1 ......
Educational Codeforces Round 153

2023.8.23 SM Round 之 OI => IOI 反向复刻:算法竞赛打 APIO,就像模拟赛用 GJOJ

# B > 给定一棵树。多次询问 $l_1,r_1,l_2,r_2$ 求 $\operatorname{lca}([l_1,r_1],[l_2,r_2])=\bigoplus\limits_{u\in[l_1,r_1],v\in[l_2,r_2]}\operatorname{lca}(u,v)$。$ ......
模拟赛 算法 Round 2023 APIO

「题解」Codeforces 825G Tree Queries

点权转边权,把边权设为两个端点的 $\min$,然后发现询问 $x$ 的答案,就是询问 $x$ 与所有黑点的虚树,边权的 $\min$ 是多少。假设要判定答案是否 $\geq k$,那么就是询问 $x$ 只经过 $\geq k$ 是否能到达所有黑点,于是想到建立 Kruskal 重构树,那么 $x$ ......
题解 Codeforces Queries 825G Tree

「题解」Codeforces 1063F String Journey

先 reverse 一下。 不难看出选出的字符串长度为 $1,2,\cdots,k$ 一定不劣,仅考虑这种形式的。 然后考虑一手 dp,设 $f_{i}$ 表示最后一个子串是 $i$ 为结尾,最长长度是多少。 这样转移就是 $f_i\gets f_{j}+1,iff\ s[j-f_j+1,j]\te ......
题解 Codeforces Journey String 1063F

牛客周赛 Round 8

# [牛客周赛 Round 8](https://ac.nowcoder.com/acm/contest/63585#question) ## [A-小美的排列询问_牛客周赛 Round 8 (nowcoder.com)](https://ac.nowcoder.com/acm/contest/63 ......
Round

AGC032 A-D题解

A 最后一次插入的数的值与位置一定相同 考虑倒着做 每次从左往右扫一遍 当遇到 a[i]==i 时将此数删除并跳出 B 当 n 为 5 时 构造出的图如下 (图形编辑器 (csacademy.com)) 那么我们猜想当 n 为奇数时将 n 与其他点连边 i 与除了 n-i 的其他点连边 证明: n ......
题解 AGC 032 A-D

round 9

大寄。 我忏悔,我对不起组长 zwb,我对不起 AK 的 Cindy,对不起比我高的 lxf 和 lzm。 T3 数组开小。 T4 计算每天翘课所对应的答案时没用暴力,而是自作聪明的用了双指针(贪心),导致一分没有。 T5 没调出来,改成了暴力。 T6 暴力打错了,导致换根没想出来。 ### T1 ......
round

Educational Codeforces Round 153 (Rated for Div. 2)

# Preface 最近CF状态烂得一批,已经连续两场被D题腐乳了,再这样下去就真成抱队友大腿的混子了 但没想到因为D题比赛时贪心过的人太多了,后面一波叉掉了比赛时过的$\frac{1}{3}$的人导致竟然还能上分我是没想到的 没抓住暑假大好的上分机会,等开学后再想冲分就难咯 # A. Not a ......
Educational Codeforces Round Rated 153

Codeforces Round 893 (Div. 2) A-C题解

CF 893 (Div.2) A. Buttons 签到题。两人会优先选择c中的按钮来,避免自己的按钮消耗同时减少对方可选择的按钮。所以c % 2 == 1等价于a的按钮数+1,c % 2 == 0时相当于c按钮不存在,比较a b 按钮的数量来得出答案即可。 #include<iostream> u ......
题解 Codeforces Round 893 A-C

Educational Codeforces Round 153 (Rated for Div. 2) C题题解

CF Edu 153 C. Game on Permutation 设必胜态指从这一格开始开始行动的某人一定能获胜,必败态同理。 从左到右遍历序列,如果左方有比自己的值的必输态,那么这一格一定可以转移到此必输态,所以这一格一定是必胜态 如果没有比自己的值小的必输态,则 比自己值小的均为必胜态。 此格 ......
题解 Educational Codeforces Round Rated

Codeforces Round 893 Div.2 A~E2

# [Codeforces Round 893 Div.2 A~E2](https://codeforces.com/contest/1858) [CF1858A](https://www.luogu.com.cn/problem/CF1858A) > 有 $a+b+c$ 个球。 > 其中的 $a$ ......
Codeforces Round 893 Div E2

P6638 「JYLOI Round 1」常规

容易把问题转换为求前缀和。设 $p$ 为当前最大的下标使得 $a_p \leq x$,则容易得到答案: $$ \text{ans} = \sum_{i = 1}^{p}\left\lfloor\dfrac{x - a_p}{k}\right\rfloor $$ 比较难直接维护,所以稍微化简一下: $ ......
常规 P6638 JYLOI Round 6638

Educational Codeforces Round 153 (Rated for Div. 2) A-A题解

# A. Not a Substring ### 题解 对于这个题,我们可以考虑两种可能的连续的子串: - 有两个及以上的相同的字符,比如`(((`,`()))`,那么我们就需要尽可能地构造出连续不相同的字符串,比如`()()()`就非常符合我们的要求,每一对都不一样。 - 有两个及以上的不相同的字 ......
题解 Educational Codeforces Round Rated

CQBZ Round 10

# CQBZ round 10 心态考爆炸了,emmmm。 最大挂点:T5 原因: 主要:对二项式反演本质理解有问题。 次要:不会及时止损。 ## [jump](http://222.180.160.110:1024/contest/4108/problem/1) 不妨设 $h_0=0$,且固定这个 ......
Round CQBZ 10

Codeforces EduRound153 Editorial

# A 如果有 $()$ 那么肯定是不合法的 有两种很简单的构造,`()()()()...()` 和 `((((...))))`,如果一个串是第一种构造的子串那么一定不是第二种构造的子串,反之亦然。 使用 python 取之 # B 把 $m\% k$ 的余数补齐,再把多出来的 $1$ 价格 reg ......
Codeforces Editorial EduRound 153

普及模拟2 +【LGR-155-Div.3】洛谷基础赛 #3 &「NnOI」Round 2

# [普及模拟2](https://www.hszxoj.com/contest/408) ## $T1$ [地址](https://www.hszxoj.com/contest/408/problem/1) $0pts$ - 简化题意:判断一个 $IP$ 地址是否合法(数据保证字符串中存在且仅存在 ......
基础 Round NnOI LGR 155

Educational Codeforces Round 153 (Rated for Div. 2)

Educational Codeforces Round 153 (Rated for Div. 2) A - Not a Substring 思路:找到串中最大的层数,若层数为1,构造层数大于1的即可;若层数大于1,构造层数为1的即可 #include<bits/stdc++.h> using n ......
Educational Codeforces Round Rated 153

「AWOI Round 2 C」数组操作?数组操作!

> [「AWOI Round 2 C」数组操作?数组操作! 洛谷](https://www.luogu.com.cn/problem/P9540 "「AWOI Round 2 C」数组操作?数组操作! 洛谷") 题目描述 给定两个长度为 $n$ 的数组 $a,b$ ,将它们合并得到一个长度为 $2\ ......
数组 Round AWOI

CodeForces 1860D Balanced String

[洛谷传送门](https://www.luogu.com.cn/problem/CF1860D "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1860/D "CF 传送门") 首先考虑一个子问题,给两个只含有 $0$ 和 $ ......
CodeForces Balanced String 1860D 1860

CodeForces 1860E Fast Travel Text Editor

[洛谷传送门](https://www.luogu.com.cn/problem/CF1860E "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1860/E "CF 传送门") 没场切。/ng 考虑将原问题转成: > 给长度为 ......
CodeForces Editor Travel 1860E 1860

Educational Codeforces Round 153 (Rated for Div. 2)

# Educational Codeforces Round 153 (Rated for Div. 2) 这次的div2有点难度,当时b题思路对了,但是没有写好 [A题传送门](https://codeforces.com/contest/1860/problem/A) ## A题意: 给你一个只 ......
Educational Codeforces Round Rated 153

「AWOI Round 2 A」最大和

嘿嘿,来水题解了。[题目链接](https://www.luogu.com.cn/problem/P9538)。 ### 题目简化 给你一个数,从它的个位到最高位进行操作,对于其每一位,你可以选择让他增加 $1$,减少 $1$(如果当前位是 $0$,减 $1$ 后会退位) 或者不变。 ### 分析 ......
Round AWOI

Codeforces Round 881 (Div. 3)

比赛链接:https://codeforces.com/contest/1843 ## A. Sasha and Array Coloring **题意**:一个数组,可以任意分成任意组,每组的贡献是组最大值减最小值,求最大总贡献 **思路**:一组内只有最大值和最小值有用,所以每组只由两个数组成即 ......
Codeforces Round 881 Div

SMU Summer 2023 Contest Round 15

# [SMU Summer 2023 Contest Round 15](https://codeforces.com/group/L9GOcnr1dm/contest/467333) ## [A. AB Balance](https://codeforces.com/group/L9GOcnr1d ......
Contest Summer Round 2023 SMU

SMU Summer 2023 Contest Round 14

# [SMU Summer 2023 Contest Round 14](https://codeforces.com/group/L9GOcnr1dm/contest/467332) ## [A. Potion-making](https://codeforces.com/group/L9GOcn ......
Contest Summer Round 2023 SMU

SMU Summer 2023 Contest Round 13

# [SMU Summer 2023 Contest Round 13](https://codeforces.com/group/L9GOcnr1dm/contest/467330) ## [A. Review Site](https://codeforces.com/group/L9GOcnr1 ......
Contest Summer Round 2023 SMU

SMU Summer 2023 Contest Round 12

# [SMU Summer 2023 Contest Round 12](https://codeforces.com/group/L9GOcnr1dm/contest/467329) ## [A. K-divisible Sum](https://codeforces.com/group/L9GO ......
Contest Summer Round 2023 SMU

Codeforces Round 893 (Div. 2)

# Preface 最战俘的一场,B题写挂一发后整个人脑子就不清醒了,放着D不写去写E1,然后忘了可持久化栈有一个经典的倍增写法,最主要当时暑假前集训我还上去讲了这个东西然后比赛的时候还没想起来 后面目送徐神爆切5题成功完成两场从蓝上橙,狠狠地把我这个在紫卡了半年的废物羞辱了一波 不过确实说实话我们 ......
Codeforces Round 893 Div

Educational Codeforces Round 109 (Rated for Div. 2)

Educational Codeforces Round 109 (Rated for Div. 2) A - Potion-making 思路:求最小操作数即药水最简比 #include<bits/stdc++.h> using namespace std; #define int long lo ......
Educational Codeforces Round Rated 109

Codeforces Round 883 (Div. 3)

比赛链接:https://codeforces.com/contest/1846 ## A. Rudolph and Cut the Rope **题意**:给n条绳子,知道一端所在高度坐标和各自绳长,他们另一端都连到一个糖果上,问至少剪掉多少绳子糖果能碰到地面 **思路**:显然只有坐标小于绳长的 ......
Codeforces Round 883 Div