codeforces pumping 1909g lemma

Codeforces Round 876 (Div. 2) 题解 A - D

## [A](https://codeforces.com/contest/1839/problem/A). The Good Array ### 题目大意 给定两个整数 $n$ 和 $k$,规定一个$01$数列为好的的条件是,对于$1\sim n$中任意的 $i$,都有: - $a$ 的前 $i$ ......
题解 Codeforces Round 876 Div

codeforces.com/contest/1553/problem/B

# [简单字符串哈希](https://codeforces.com/contest/1553/problem/B) ## 题意 给一个字符串s和t,问从s的某个位置开始,向右到某个点后再向左,顺序遍历到的字符形成的字符串可否为t。 ## 思路 数据只有500,$O(n^3)$可过,枚举转折点,然后 ......
codeforces contest problem 1553 com

Codeforces Round 876 (Div. 2) A-D

[比赛地址](https://codeforces.com/contest/1839/my) ## A.The Good Array 题意:定义一个数组是good的要求有: 从左往右所有的i,前i个数中至少有[i/k]个数是1 从右往左所有的i,前i个数中至少有[i/k]个数是1 问good数组对于 ......
Codeforces Round 876 A-D Div

codeforces 1200-1400板刷

2023.6.6 C. Scoring Subsequences(二分)(1300) C. Where is the Pizza?(并查集判断环)(1400) D. Vertical Paths (dfs,写法上对于处理叶子节点可以优化)(1300) ......
板刷 codeforces 1200 1400

Codeforces 1566G - Four Vertices(线段树分治)

交了整整 2 页,本来想用随机化卡过去的,后来发现我的实现跑得太慢就写正常做法了。 首先发现最优答案对应的四个点只可能有以下两种可能: - $a,b$ 间有边,$c,d$ 间有边,此时答案是 $a,b$ 边权值加 $c,d$ 边权值。 - $a$ 与 $b,c,d$ 三个点间都有边,此时答案是三条边 ......
线段 Codeforces Vertices 1566G 1566

Codeforces 1801D The way home

看到 `shortest paths` 来做的。 首先有一个贪心的策略,对于当前点 $u$ 若不能直接往后走则肯定是选择经过的点中 $w_i$ 最大的加。 很好理解,证明就不需要了。 所以可以定义状态 $f_{u, mx}$ 为 $u$ 点最大能加的值为 $h_{mx}$ 的最优状态,$h$ 是 $ ......
Codeforces 1801D 1801 home The

Codeforces 1588F - Jumping Through the Array

显然无法用 polylog 的数据结构维护,序列分块也不行,考虑询问分块。每 $B$ 个询问处理一次。 将这个询问中 $2,3$ 操作涉及到的点设为“关键点”,那么容易发现,环上每一段以关键点结尾的链在这块操作的过程中始终保持不变,也就是说我们可以把它们缩在一起。 先预处理出每个块的增量对每组询问的 ......
Codeforces Jumping Through 1588F Array

Codeforces 1495F - Squares

不知道怎么放到 div1F 的,感觉没啥亮点。 首先对于一条 $1$ 到 $n+1$ 的路径而言,它经过的点的编号一定是递增的,也就是说,如果我们将关键点大小排个序,那么答案就是相邻两点间最短路的和。删 / 加点造成的变化是 $O(1)$ 的,所以问题等价于,多次询问这张图中 $x,y$ 之间最短路 ......
Codeforces Squares 1495F 1495

Codeforces 1299E - So Mean

先考虑一个平方的做法。我们先问出 $1,n$:遍历所有元素,删掉它以后问一下剩余 $n-1$ 个元素形成的集合,如果是 $n-1$ 的倍数说明这个元素要么 $1$ 要么 $n$,由于两个排列是镜像的所以任意钦定一个是 $1$ 一个是 $n$ 即可。删掉两个元素以后归纳问剩余部分也可以知道 $2,n- ......
Codeforces 1299E 1299 Mean So

CodeForces 1838E Count Supersequences

[洛谷传送门](https://www.luogu.com.cn/problem/CF1838E "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1838/E "CF 传送门") **结论:$a_i$ 对答案没有影响。** 考虑 ......
Supersequences CodeForces 1838E Count 1838

Codeforces 1737G - Ela Takes Dancing Class(平衡树)

数据结构好题。 先考虑如果 $s_i$ 全是 $1$ 怎么做。考虑一个非常特殊的状态:如果当前最靠左的舞蹈者跳一步就能跳到最靠右的舞蹈者的右边,那么这样的局面性质其实是非常完美的。因为容易归纳证明,这样的局面下,每一步最靠左的舞蹈者跳一步都能跳到最靠右的舞蹈者的右边,这样一来,如果维护出了初始局面下 ......
Codeforces Dancing 1737G Class Takes

Codeforces Round 876 (Div. 2)

# Preface DP腐乳闪总出列! (本来以为大掉分的一把,但这个号因为挺新的所以竟然还能上挺多分的,压线完成了5场上紫) 早知道去做E题了,感觉CF真得要看题目相性,有些题目就是一眼感觉不适合自己的说 # A. The Good Array 一个要动点脑子的签到题,因为$a_1,a_n$必须等 ......
Codeforces Round 876 Div

Codeforces Round 876 (Div. 2)题解

# [Codeforces Round 876 (Div. 2)](https://codeforc.es/contest/1839 "Codeforces Round 876 (Div. 2)") ## [A. The Good Array](https://codeforc.es/contest ......
题解 Codeforces Round 876 Div

2023.5 codeforces 杂题选做

## 2023.5 codeforces 杂题选做 #### [E. Location](https://codeforces.com/contest/1732/problem/E) $n\le 5\times 10^4$ 的范围,并且区间赋值、区间维护最值,可以考虑分块。然后对于散块的修改可以直接 ......
codeforces 2023.5 2023

Codeforces 1833E Round Dance

看到 `shortest paths` 来做的,但是好像没啥关系也没啥难度。 首先能知道一个连通块肯定一次就能跳完,所以可以把连通块缩出来。 然后有一个性质,记 $cz_i$ 为 $i$ 连通块内点种通过已知边推出的度数为 $1$ 的个数为 $cz_i$,则 $cz_i\bmod 2 = 0$。 记 ......
Codeforces 1833E Round Dance 1833

Codeforces 1515I - Phoenix and Diamonds(值域倍增+线段树)

首先 $c$ 很大,因此复杂度跟 $c$ 有关的项肯定只能是 $\log c$ 之类的。 类比 IOI2021 dungeons 的套路,我们**对值域进行分层**,假设 $c\in[2^{\omega-1},2^{\omega})$,考虑令重量在 $\ge 2^{\omega-1}$ 的物品为“重 ......
值域 线段 Codeforces Diamonds Phoenix

Codeforces Round 875 (Div. 2)B-D

原题链接:https://codeforces.com/contest/1831 原文:https://www.cnblogs.com/edgrass/p/17440602.html (B) Array merging 主体思想是找到ab数组的最长相同字串(c中操作可实现连续) 1 #include ......
Codeforces Round 875 B-D Div

Educational Codeforces Round 149 (Rated for Div. 2)

# A. Grasshopper on a Line ```cpp #include using namespace std; #define int long long void solve(){ int x , k; cin >> x >> k; if( x % k == 0 ){ cout > ......
Educational Codeforces Round Rated 149

Codeforces Round 875 (Div. 2) 题解 A ~ D

## [A](https://codeforces.com/contest/1831/problem/A). Twin Permutations ### 题目大意 题目给定一个 $1\sim n$ 的排列 $a$ ,现在想求一个排列 $b$, 使得对于 $i #include #include #d ......
题解 Codeforces Round 875 Div

Codeforces Round 875 (Div. 2) A-D

## A. Twin Permutations 题意:给出一个由[1,2,...,n]组成的数组a,构造另一个由[1,2,...,n]组成的数组b,使得a[1]+b[1]>n; for(int i=1;i>a[i]; } for(int i=1;i>n; for(int i=1;i>a[i]; fo ......
Codeforces Round 875 A-D Div

Codeforces Round 875 (Div

# Codeforces Round 875 (Div. 2) C-D题解 ### C [Problem - C - Codeforces](https://codeforces.com/contest/1831/problem/C) 我们发现题述所形成的父亲节点一定比子节点先画出,并且如果子节点顺 ......
Codeforces Round 875 Div

Codeforces Round 875 (Div. 2)

# Preface 难得现场打一次,这天下午打了三个半小时的校内赛,然后八点打了两小时ARC,最后再接上两个半小时的CF真是爽歪歪 不过有一说一其实很多时候都在坐牢,这场CF也差不多,一个小时写完ABCD然后开始坐牢,其实E基本想出来了但是没想到用随机赋值的方法来实现 不过由于这场手很稳因此排名极高 ......
Codeforces Round 875 Div

Codeforces Round 874 (Div. 3)

# A. Musical Puzzle ```cpp #include using namespace std; void solve(){ int n; string s; cin >> n >> s; set cnt; for( int i = 0 ; i + 1 > t; while( t - ......
Codeforces Round 874 Div

Codeforces Round 875 (Div. 2) A-D

# Codeforces Round 875 (Div. 2) ## A. Twin Permutations ```c++ int a[N]; void solve(){ int n=read(); for(int i=1;i0?"YES":"NO"); //puts(ans>0?"Yes":"N ......
Codeforces Round 875 A-D Div

CodeForces 1830D Mex Tree

[洛谷传送门](https://www.luogu.com.cn/problem/CF1830D "洛谷传送门") [CF 传送门](https://codeforces.com/contest/1830/problem/D "CF 传送门") 考虑答案的下界。 对整棵树进行二分图染色,我们得到答案 ......
CodeForces 1830D 1830 Tree Mex

CodeForces 1830C Hyperregular Bracket Strings

[洛谷传送门](https://www.luogu.com.cn/problem/CF1830C "洛谷传送门") [CF 传送门](https://codeforces.com/contest/1830/problem/C "CF 传送门") 每一步思路都非常自然的题。 考虑先从一些简单的 cas ......

Codeforces Round #875 (Div. 2)

# Codeforces Round #875 (Div. 2) [bilibili: Codeforces Round #875 (Div. 2) 实况 | 完成度 \[4.01 / 6\]](https://www.bilibili.com/video/BV1bo4y137he) ## A `` ......
Codeforces Round 875 Div

Codeforces Round 875 (Div. 2) A~D

# Codeforces Round 875 (Div. 2) A~D ### A. Twin Permutations 构造$a[i]+b[i]=n+1$ ```c++ void work() { int n; cin >> n; rep (i, 1, n) { int x; cin >> x; ......
Codeforces Round 875 Div

Educational Codeforces Round 149 (Rated for Div.2) 题解 A~D

## [A](https://codeforces.com/contest/1837/problem/A). Grasshopper on a Line ### 题目大意 给定两个整数 $x$ 和 $k$,我们需要规划一条路线,从 $(0,0)$ 走到 $(0, x)$,同时满足我们每次走的距离不能 ......
题解 Educational Codeforces Round Rated

Codeforces 1740I - Arranging Crystal Balls

(注:默认下标 1-indexed) 考虑一个数组被清零的充要条件:记 $b_i=a_{i}-a_{(i+n-2)\bmod n+1}$,那么最终 $a_i=0$ 当且仅当 $b_i=0$ 且 $a_1=0$。 思考一次操作的影响:假设我们对 $[x,x+k-1]$ 这段环上的区间进行了 $+v$, ......
Codeforces Arranging Crystal 1740I Balls