codeforces pumping 1909g lemma

Codeforces Round 776 (Div. 3) B. DIV + MOD

定义函数 \(f_a(x) = \lfloor \frac{x}{a} \rfloor + x \mod a\) 。 回答 \(q\) 个独立询问,每个询问给出 \(l, r, a(1 \leq l,r,a \leq 10^9)\) ,询问 \(f_a(x)\) 在定义域 \([l,r]\) 上的最 ......
Codeforces Round 776 Div DIV

Codeforces Round 781 (Div. 2) B. Array Cloning Technique

给一个长度为 \(n\) 的数组 \(a\) 。开始只有一份所给 \(a\) 的副本。你可以做以下两种操作: 选择任意一个副本并且克隆它,然后将会多出一个克隆副本。 交换两个元素,他们属于任意两个副本(可能是同一个)。 需要判断最小操作数,使有一个副本的所有元素相同。 观察一:只需要在开始的副本上让 ......
Codeforces Technique Cloning Array Round

Codeforces Round 787 (Div. 3) B. Make It Increasing

给一个长为 \(n\) 的数组 \(a_1, a_2, \cdots, a_n \quad (0 \leq a_i \leq 10^9)\) 。可以执行以下操作任意次: 选择任意一个 \(a_i\) 并且执行 \(a_i = \lfloor \frac{a_i}{2} \rfloor\) 。 输出最 ......
Codeforces Increasing Round Make 787

Codeforces Round 897 (Div. 2)

Preface 这场周一晚上因为沉迷玩《Chaos Child》就没打,赛后点开一看人傻了怎么E2都有1k+的人过 后面补了下发现确实全是丁真题,早知道给小号上上分了 A. green_gold_dog, array and permutation 签到题,把大的\(a_i\)和小的数匹配即可 #i ......
Codeforces Round 897 Div

Codeforces Round 791 (Div. 2) A. AvtoBus

已知有 \(n\) 个轮子,会有一个车队车来换轮,且恰好使用完这些轮子。只知道这些车中有 \(4\) 轮车和 \(6\) 轮车。你需要估计这个车队最少可能有多少车和最多可能有多少车,或判断这是完全不可能的。 观察:\(4x + 6y = n\) ,由裴蜀定理,当 \(2 \mid n\) 有解且 \ ......
Codeforces AvtoBus Round 791 Div

Codeforces Round 783 (Div. 2) B. Social Distance

\(m\) 张椅子被顺序排成一个圈,编号从 \(0\) 到 \(n - 1\) , \(n\) 个人打算入座,第 \(i\) 个人希望左右 \(a_i\) 张椅子没有人坐。是否存在满足所有的意愿的情况下可以全部入座。\(n\) 个人不必顺序入座。 观察一:总共有 \(m\) 张椅子,\(n\) 个人 ......
Codeforces Distance Social Round 783

Codeforces Round 897 (Div. 2)

目录写在前面ABCDE1/E2F写在最后 写在前面 比赛地址:https://codeforces.com/contest/1867。 简略题解。 还好没掉分。 A 令原数列中第 \(k\) 大对应 \(k\) 即可。 // /* By:Luckyblock */ #include <bits/st ......
Codeforces Round 897 Div

CodeForces 1801G A task for substrings

洛谷传送门 CF 传送门 区间显然不好处理,考虑转化成前缀和后缀。 设 \(f'_i\) 为 \(T[1 : i]\) 的单词出现次数,\(f_i\) 为 \(f'_i\) 的前缀和,\(g_i\) 为 \(T[1 : i]\) 后缀最长的单词编号。都可以通过建 \(s_i\) 正串的 ACAM 预 ......
CodeForces substrings 1801G 1801 task

【题解】Educational Codeforces Round 141(CF1783)

评价:educational A.Make it Beautiful 题目描述: 如果一个数组中存在一个数恰好等于该数前面所有数之和,那么这个数组就是丑的。如果一个数组不是丑的,就是美的。 比如说: 数组 $ [6, 3, 9, 6] $ 是丑的,因为 \(9 = 6 + 3\) ; 数组 $ [5 ......
题解 Educational Codeforces Round 1783

CodeForces 1517F Reunion

洛谷传送门 CF 传送门 典? 考虑枚举 \(r\),算有多少种方案使得,存在一个点,离它最近的黑点距离 \(> r\)。 设 \(f_{u, i}\) 为 \(u\) 子树内离 \(u\) 最近的黑点距离为 \(i\)。如果一个点子树中离它最近的黑点距离 \(> r\),那么它就已经满足子树的限制 ......
CodeForces Reunion 1517F 1517

Educational Codeforces Round 34 (Rated for Div. 2) C(multiset、思维)

C. Boxes Packing 思路:每一次选择一段递增的子段, 将其删除, 最高的一个会能够被看到。这个过程可以用 std::multiset 模拟, 主要是两个函数的应用: extract(x):删除集合中的一个 $ x $,upper_bound(x):返回集合中第一个大于 $ x $ 的元 ......
Educational Codeforces multiset 思维 Round

Codeforces Round 895 (Div. 3)

Codeforces Round 895 (Div. 3) A. Two Vessels 解题思路: \(d = \lceil {\frac {abs(a - b)} 2}\rceil\) \(ans = \lceil {\frac d c}\rceil\) 代码: #include <bits/s ......
Codeforces Round 895 Div

Codeforces Round 897 (Div. 2)

Codeforces Round 897 (Div. 2) 比赛链接 A. green_gold_dog, array and permutation 题目 给你一个长度为n的数组a,要求你找出一个数组长度为n的数组b,大小是1-n,保证每个数字出现一次,使得a数组与b数组对应位置上的差值和最大。 ......
Codeforces Round 897 Div

Codeforces Round 897 (Div. 2)

F. Most Different Tree 当 \(n=2\) 时,只能构造一条长度为 \(2\) 的链。 当 \(n\ge 3\) 时,对于 \(i\) \((1\le i\le n)\),以 \(i\) 作为根的树记为 \(h_i\),考虑枚举树找一个大小为 \(s\) 的树 \(t\),使得 ......
Codeforces Round 897 Div

Codeforces Round 897 (Div. 2)

Codeforces Round 897 (Div. 2) A. green_gold_dog, array and permutation 分析: 由题意: \[c_i = a_i - b_i \]\(c_i\)种类最多就是\(n\)个数都不同。 若\(a_i\)不断变大,\(b_i\)不断变小, ......
Codeforces Round 897 Div

atcode abc318,codeforce 1861

题目链接 题解 目录AtCoder abc318_a Full MoonAtCoder abc318_b Overlapping sheetsAtCoder abc318_c Blue SpringAtCoder abc318_d General Weighted Max MatchingAtCod ......
codeforce atcode 1861 abc 318

Codeforces Round 897 (Div. 2) A~E

Codeforces Round 897 (Div. 2) A~E A: 原先数组里面最小的位置放最大的数,次小的放次大的即可。 void solve(){ int n; cin>>n; for(int i=1;i<=n;i++){ int x; cin>>x; c[i]={x,i}; } sort ......
Codeforces Round 897 Div

Codeforces Round 896 (Div. 2)

Codeforces Round 896 (Div. 2) A. Make It Zero 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; using i128 = __int128; int n, m; ......
Codeforces Round 896 Div

[2022 China Collegiate Programming Contest (CCPC) Guilin Site](https://codeforces.com/gym/104008) CEM

2022 China Collegiate Programming Contest (CCPC) Guilin Site CEM C. Array Concatenation 思路:数学推柿子 考虑有两种操作: 复制 \(b' = \{b_1,b_2,...,b_{|b|},b_1,b_2,..., ......

$Codeforces Round 897 (Div. 2)$

\(A. green_gold_dog, array and permutation\) 让大的数减小的数就可以制造更多的不同。 PII a[N]; int ans[N]; void solve(){ int n=read(); for(int i=1;i<=n;i++){ a[i]=make_pa ......
Codeforces Round 897 Div

CodeForces 542B Duck Hunt

洛谷传送门 CF 传送门 首先转化一下,让鸭子不动,猎人往右移动,就相当于开的相邻两枪距离 \(> m\)。 设 \(f_{x, i}\) 为仅考虑 \(r \le x\) 的鸭子,上一次在 \(i\) 开枪,能打到的最大鸭子个数。 \(f_{x - 1} \to f_x\) 时,首先有 \(f_{ ......
CodeForces 542B Duck Hunt 542

Codeforces Round 896 (Div. 1)

Preface 不管怎么说,最后还是被我苟上橙名了(虽然刚好2100整,不多不少) 感觉我在1900~2100之间卡了好久好久,反观我的队友都是打上紫名后随便两三场就打上橙了,狠狠地羞辱我这个铁混子 由于暑假集训打的校内排名比较高,作为新队伍也拿到了今年的一场CCPC+一场ICPC的名额,虽然要自费 ......
Codeforces Round 896 Div

Codeforces Round 101 (Div. 2) C - E

C. Queue (思维、排序、构造、*1800) 题意:$ n $ 个人排队, 为他们构造一组身高, 使得 $ x $ 的前面有 $ a_i $ 个人比他高。如果无法构造满足所有条件的身高序列, 输出 -1。 思路:首先考虑, 对于 $ a_i $ 较大的人, 肯定尽可能地将其往队伍后面放, 然后 ......
Codeforces Round 101 Div

Codeforces Round 896 (Div. 2) A-D2

A. Make It Zero 没看懂这个 8 次的限制是什么意思。先用一次直接把所有数变成 \(\oplus_{i=1}^n a_i\),如果 \(n\) 是偶数直接 \([1,n]\) 做完,如果是奇数先把 \([1,n-1]\) 变成 0,再做两遍 \([n-1,n]\) 即可。 点击查看代码 ......
Codeforces Round 896 A-D Div

【题解】Educational Codeforces Round 142(CF1792)

没有手速,再加上被 E 卡了,废掉了。 A.GamingForces 题目描述: Monocarp 正在玩电脑游戏。他打算杀死 \(n\) 个怪兽,第 \(i\) 个的血量为 \(h_i\)。 Monocarp 的角色有两个魔法咒语如下,都可以以任意顺序用任意次(可以不用),每次使用相当于一次操作。 ......
题解 Educational Codeforces Round 1792

Codeforces Round 895 (Div. 3)

Codeforces Round 895 (Div. 3) A - Two Vessels 思路:找到差值,让a,b向中间靠 #include<bits/stdc++.h> using namespace std; #define int long long //#define int __int1 ......
Codeforces Round 895 Div

Codeforces Round 798 (Div. 2) B. Mystic Permutation

给一个长为 \(n\) 的排列 \(p\) ,需要构造一个长为 \(n\) 的排列 \(q\) ,满足 \(\forall i, p_i \neq q_i\) ,且 \(q\) 在所有合法排列中字典序最小。 观察一:\(n = 1\) 时无解,否则有解。 观察二:\(n > 1\) 时,\(1 \s ......
Permutation Codeforces Mystic Round 798

Codeforces Global Round 21 B. NIT Destroys the Universe

给一个长为 \(n\) 的数组,可以执行以下操作任意次: 选择 \(l, r(1 \leq l < r \leq n)\) ,让 \(\forall i(l \leq i \leq r), a_i = mex(\{a_l, a_{l+1}, \cdots, a_{r}\})\) 。 问最小操作数使得 ......
Codeforces Destroys Universe Global Round

Educational Codeforces Round 132 (Rated for Div. 2) B. Also Try Minecraft

一个世界地图用一个长为 \(n\) 的数组表示,\(a_i\) 代表坐标 \(i\) 的高度。若下一块区域的高度为 \(y\) ,当前区域的高度为 \(x\) ,则一次行走会受到 \(max(y - x, 0)\) 点下落伤害。 有 \(q\) 个询问,每个询问独立,给定起点和终点坐标 \(s, t ......
Educational Codeforces Minecraft Round Rated

Educational Codeforces Round 130 (Rated for Div. 2) B. Promo

有 \(n\) 件商品,第 \(i\) 件的价格是 \(p_i\) ,若买至少 \(x\) 件商品,则其中最便宜的 \(y\) 件免费。给 \(q\) 个询问,每次给出 \(x, y\) ,回答最多能免费的价值。 按大到小排序,求前缀和 \(S_{i}\) 表示买前 \(i\) 件商品需要的开销。 ......
Educational Codeforces Round Rated Promo