codeforces pumping 1909g lemma

Codeforces 1329E - Dreamoon Loves AA

思考下什么样的 $l,r$ 是合法的:显然对于一组长度为 $len$ 的空隙,要使得相邻两个 A 之间的距离在 $[l,r]$ 中,你新插入的 A 的个数应该位于 $[\lceil\dfrac{len}{r}\rceil-1,\lfloor\dfrac{len}{l}\rfloor-1]$ 中。因此 ......
Codeforces Dreamoon 1329E Loves 1329

Codeforces 1830E - Bully Sort

这种题肯定首先要**寻找不变量**。 显然后面排好序的后缀不会被改变。因此从整体上来看我们的流程肯定是,如果当前 $p_n=n$,就令 $n$ 减一,否则你一步换的 $i$ 肯定满足 $p_i=n$。而显然 $\min\limits_{j=i}^np_j\le i$,因此我们考察 $\sum|i-p ......
Codeforces 1830E Bully 1830 Sort

Codeforces 794G - Replace All

一个比较垃圾的做法,卡着时限过了这道题。 首先大胆猜个结论:要么 $|s|=|t|$,此时 $A,B$ 任取,要么存在字符串 $c$ 和整数 $x,y$ 使得 $A=c^x,B=c^y$,其中 $c^x$ 表示 $x$ 个 $c$ 拼接得到的结果。证明的话感觉还挺复杂的,可能要 border 引理之 ......
Codeforces Replace 794G 794 All

Codeforces 1662J - Training Camp

这种数据范围和题目特点一眼网络流。 对于一种选法,我们考虑建立两个黑白矩阵,如果一个点 $(i,j)$ 被选,我们就将第 $i$ 行中 $a_{i,k}\le a_{i,j}$ 的 $(i,k)$ 在第一张网格图中染成黑色,将第 $j$ 列中 $a_{k,j}\le a_{i,j}$ 的点 $(k, ......
Codeforces Training 1662J 1662 Camp

Codeforces Round 501 (Div. 3)

Codeforces Round 501 (Div. 3) A - Points in Segments 思路:记录每个区间 #include<bits/stdc++.h> using namespace std; #define int long long //#define int __int1 ......
Codeforces Round 501 Div

Codeforces 1470F - Strange Covering

一年前模拟赛的题,时隔恰好一年零一天又考了一遍还是不会做。 对两个矩形的位置分情况: 1. 相离,此时必然存在一条与 $x$ 轴或 $y$ 轴平行的分界线,满足一个矩形在左边(下面),另一个矩形在右边(上面)。这部分显然可以 $O(n)$ 地处理。 2. 相交成十字形。这一类我的处理比较烦:考虑预处 ......
Codeforces Covering Strange 1470F 1470

Codeforces 856F - To Play or not to Play

首先,DP 肯定是逃不掉的,因为直接贪心其实不好判断在两个人都可以上线的时间段究竟是哪个人上线,需要通过后面的情况来做出判断,但是这题值域比较大直接维护 DP 值肯定不行,因此考虑先设计一个与值域有关的 DP 然后优化。 将时间区间离散化,然后依次考虑每个时间区间。一个很自然的想法是设 $dp_{i ......
Play Codeforces 856F 856 not

Codeforces Round div.2 C

Smiling & Weeping 我对姑娘的喜欢,何止钟意二字 题目链接:Problem - C - Codeforces 自我分析:我感觉这是一道很有意义的题目,可以帮我们更好的理解二进制的本质 思路:首先先了解一下题目,我们是求由第i个数到末尾的异或和(异或:相同为0,不同为1),那么我们可以 ......
Codeforces Round div

Codeforces 1787I - Treasure Hunt

注意到这什么 $s>q$ 或 $t\le q$ 的限制条件是没有用的,因为如果 $s\le q>1;solve2(l,mid);solve2(mid+1,r); static ll mn[MAXN+5],mx[MAXN+5],f[MAXN+5],g[MAXN+5]; mn[mid+1]=mx[mid ......
Codeforces Treasure 1787I 1787 Hunt

Codeforces Round 882 div.2 B

Smiling & Weeping 玫瑰花你拿才好看,风景要和你看才浪漫--<-<-<@ B. Hamon Odyssey time limit per test 1 second memory limit per test 256 megabytes input standard input ou ......
Codeforces Round 882 div

Codeforces 1696G - Fishingprince Plays With Array Again

初读题目可以发现一些性质: - 每次操作会使整个序列的和减少至多 $X+Y$,因此 $ans\ge\dfrac{\sum a_i}{X+Y}$。 - 对于两个不相邻位置 $a_i,a_j(|i-j|>1)$,每次操作最多使它们的和减少 $\max(X,Y)$。 然后你发现两个限制可以结合在一起使用, ......
Fishingprince Codeforces 1696G Array Again

Codeforces 1446F - Line Distance

[感觉这种类似于让你找第 $k$ 大距离的计算几何题其实都挺套路的。](https://www.cnblogs.com/tzcwk/p/Codeforces-607E.html) 二分一个答案 $t$,然后思考一下什么样的点对满足原点到它们的连线的距离 $\le t$。以原点为圆心 $t$ 为半径画 ......
Codeforces Distance 1446F 1446 Line

Codeforces 1621H - Trains and Airplanes

这能 3500? 对于一组在 $u$ 上的询问,考虑每种线路 $x$,假设 $1\to u$ 路径上线路 $x$ 的长度为 $len$,那么不难发现收罚款的次数只有两种可能:$\lfloor\dfrac{len}{T}\rfloor$ 或者 $\lfloor\dfrac{len}{T}\rfloor ......
Codeforces Airplanes Trains 1621H 1621

Codeforces 1785E - Infinite Game

很没感觉的一道题。 首先特判掉 $n\le 2$。 在 $s$ 无穷拼接的过程中,我们考虑一个周期一个周期地匹配,由于每局比赛的长度是 $2$ 或者 $3$,因此每个周期开始的时候,把上个周期剩下的零头匹配完之后起始匹配位置只可能是 $0$ 或 $1$ 或 $2$,并且对于一个起始匹配位置 $i(0 ......
Codeforces Infinite 1785E 1785 Game

Educational Codeforces Round 151

### AB 略 ### C(简) 将密码 $P$ 与 $S$ 进行匹配,按顺序决定 $P_i$,为了避免 $P$ 成为 $S$ 的子串,每次贪心地选择当前匹配位置最靠后的。若出现匹配不上则“YES”。 ### D 有点意思。从基础的情况入手: 设 $\{s_i\}$ 为 $\{a_i\}$ 的前缀 ......
Educational Codeforces Round 151

Codeforces Round 882 div.2 A

Smiling&Weeping 总有人间一两风,填我十万八千梦 A. The Man who became a God time limit per test 1 second memory limit per test 256 megabytes input standard input outp ......
Codeforces Round 882 div

Codeforces Round 885 (Div. 2)

# Preface 打的就是依托答辩居然也能上分,看来手稳还是重要的说 D题半场开香槟以为随便写,然后没想到怎么处理这个局部没有三分性的函数,直接GG 后面听学长一说其实分成四种函数分别求最值即可直接恍然大悟,只能说还是太菜太菜 而且F好像是个蓝桥杯的某个题的弱化版,我说比赛的时候怎么那么多人艹过去 ......
Codeforces Round 885 Div

Codeforces 1172F - Nauuo and Bug

是 Ynoi 捏。 建一棵线段树,线段树上每个节点维护一个长度为 $len$ 的 DP 数组 $f_i$ 表示 $v$ 最少需要多少才能使得从左往右将 $v$ 与区间中的数进行图中的相加操作后会减掉至少 $i$ 次 $p$。 如果我们能预处理出 $f_i$,那么查询是容易的,直接找到对应的区间然后 ......
Codeforces 1172F Nauuo 1172 Bug

Codeforces Round 885

[TOC] ### 写在前面 比赛地址:[https://codeforces.com/contest/1848](https://codeforces.com/contest/1848)。 我现在手里有三套题要补呃呃 这套是两天前补的了,所以简单写写。 太好玩辣,多校! ### A 考虑一个 2x ......
Codeforces Round 885

Codeforces Round #885 (Div. 2) A-D

[比赛链接]() # A ## 代码 ```c++ #include using namespace std; using ll = long long; bool solve() { int n, m, k; cin >> n >> m >> k; int x, y; cin >> x >> y; ......
Codeforces Round 885 A-D Div

Codeforces Round 885 (Div. 2)

# A. Vika and Her Friends 枚举所有的点,判断是否存在点与Vika的距离和其他 k 个人的距离的奇偶性不同。 ```cpp #include using namespace std; #define int long long const int mod = 99824435 ......
Codeforces Round 885 Div

Codeforces Round 885 (Div. 2)

Codeforces Round 885 (Div. 2) A - Vika and Her Friends 思路:移动后再判断,所以距离为奇数时朋友永远抓不到她 #include<bits/stdc++.h> using namespace std; #define int long long t ......
Codeforces Round 885 Div

Educational Codeforces Round 65

# A. Telephone Number 找到第一个 8 ```cpp #include using namespace std; #define int long long const int mod = 998244353; #define mp make_pair void solve() ......
Educational Codeforces Round 65

CodeForces 1848E Vika and Stone Skipping

[洛谷传送门](https://www.luogu.com.cn/problem/CF1848E "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1848/E "CF 传送门") 感觉比这场的 F 简单。 发现我们要进行 $x$ ......
CodeForces Skipping 1848E Stone 1848

Codeforces Round 885 (Div. 2) A-D

## A. Vika and Her Friends 题意:有一个n*m大小的矩阵,vika在点(a,b),她的k个朋友在分别(xi,yi),所有人每分钟都可以上下左右走一格,每一分钟vika先走,她的朋友后走,不能不走,问vika能否躲过朋友。 ### Solution 结论题,只要有一个朋友和她 ......
Codeforces Round 885 A-D Div

Codeforces Round #885(Div. 2)C

##C. 维卡和价格标签 每个测试的时间限制为1秒 每个测试的内存限制为256兆字节 输入:标准输入 输出:标准输出 维卡来到她最喜欢的化妆品店"Golden Pear"。她注意到n个物品的价格自她上次光顾以来发生了变化。 她决定分析价格的变化,并计算每个物品的旧价格和新价格之间的差异。 维卡喜欢计 ......
Codeforces Round 885 Div

Codeforces Round 885 (Div. 2) B

## B. 维卡和木桥 每个测试的时间限制为1秒 每个测试的内存限制为256兆字节 输入:标准输入 输出:标准输出 夏天,维卡喜欢去她的乡间别墅。那里有一切供放松的设施:舒适的秋千、自行车和一条河流。 河上有一座木桥,由n块木板组成。它相当老旧而不吸引人,所以维卡决定给它上漆。在小屋里,他们找到了k ......
Codeforces Round 885 Div

Codeforces Round #885 (Div.2) Editorial

B - Vika and the Bridge 题意:从桥的一边走到另一边,每次只能踩在相同颜色的木板上,并且有一次操作,可以修改期中一个模板的颜色。 问那种走法,跨过模板的最大值最小。 思路:首先可以统计出选择每种颜色的,跳过木板的的个数,如果不能修改颜色,那么答案一定是每个颜色所对应的最大值的最 ......
Codeforces Editorial Round 885 Div

Codeforces Round 883 (Div. 3)

只写部分题目。 ## A. Rudolph and Cut the Rope ```cpp #include using namespace std; #define int long long const int N = 2e5 + 5; int t, n, a[N], b[N]; signed ......
Codeforces Round 883 Div

CodeForces 1844G Tree Weights

[洛谷传送门](https://www.luogu.com.cn/problem/CF1844G "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1844/G "CF 传送门") 出题人脑洞真大…… 设 $x_i$ 为 $i$ ......
CodeForces Weights 1844G 1844 Tree