codeforces pumping 1909g lemma

Codeforces Round 905 div2 F题

记答案为\(ans_i\),表示从1到i次修改出现的字典序最小的数组a, \(c\)数组表示\(ans_i\)出现之后,所有修改的累加和。用一个vector存一下\(ans_i\)之后的所有修改。从1到q遍历每一次修改时,对\(c\)数组进行区间赋值操作,如果\(c\)数组中第一个不为0的数<0,那 ......
Codeforces Round div2 905 div

「解题报告」Codeforces Round 653 (Div. 3)

A. Required Remainder You are given three integers \(x, y\) and \(n\). Your task is to find the maximum integer \(k\) such that \(0 \le k \le n\) that ......
Codeforces 报告 Round 653 Div

Codeforces Round 905 (Div. 2)

Preface 周日晚上Div1,2,3同乐,但我不想打Div1,同时第三个号由于只打了两场没够到Div2的门槛,因此刚好打不了Div2,遂玩了一晚上LOL 今天补了下这场题感觉难度偏低,E之前的题都比较签,F刚开始没想到转化成差分最小准备去写扫描线+线段树了,后面发现其实可以写的很简单 A. Ch ......
Codeforces Round 905 Div

CodeForces 946F Fibonacci String Subsequences

洛谷传送门 CF 传送门 duel 的时候差点不会 2400 了。 套路地,考虑每个 \(F(x)\) 中与 \(s\) 相同的子序列的贡献。设这个子序列为 \(F(x)_{p_1}, F(x)_{p_2}, F(x)_{p_3}, \ldots, F(x)_{p_n}\)。 我们想要它成为一个子序 ......

Codeforces 1862G 题解

传送门 题解 因为有这个操作:将序列 \(a\) 加上 \(\{n, n - 1, \cdots, 1\}\),考虑差分。 那么显然每次操作会将差分数组中的每个元素减去 \(1\),如果差分数组中有 \(0\),就会把 \(0\) 删除。 所以可以发现差分数组中剩下的一定是操作前的最大值。 由于操作 ......
题解 Codeforces 1862G 1862

Educational Codeforces Round 127(CF1671 D~E) 题解

D. Insert a Progression 题目链接 可以瞪出来的一个结论就是当我们在位置 \(p\) 插入了一个数 \(x\) 时,如果存在一对 \(l,r\) 满足 \(l<p\),\(r>p\) 且 \(x\in[a_l,a_r]\),那么我们插入的这个 \(x\) 就不会对序列的答案产生 ......
题解 Educational Codeforces Round 1671

Codeforces Round 886 (Div. 4) 题解

link 我为什么还要 vp div4 场。。。 A 直接找最大的两个判断一下。 void solve() { int a[3]; cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); if(a[2] + a[1] >= 10) cout << "YES\n"; ......
题解 Codeforces Round 886 Div

Codeforces Round 905 (Div. 3)

Codeforces Round 905 (Div. 3) A. Morning 解题思路: 首先\(4\)个数字都要打印出来,所以\(ans\)起始值为\(4\)。 接着就是从左向右移动绝不回头,鼠标移动的距离和就是两两数字之差。 注意:这里\(0\)位置其实是\(10\). 代码: #inclu ......
Codeforces Round 905 Div

Codeforces Round#905 解题报告

由于是解题报告不是过题报告,所以理所当然的放弃了后三题代码的写。 感觉这场 Div1 D 是 cyh 的菜,E 是 gjk 的菜。我负责菜。 只写 Div1 题的题解。 A 双指针可以做 \(m=1\) 你发现随便换 \(a_1\) 答案最多减少 \(1\),而且 \(a_1\) 越趋向于减少,所以 ......
Codeforces 报告 Round 905

Codeforces Round 905 (Div. 2) D1. Dances (Easy version)(贪心+二分)

Codeforces Round 905 (Div. 2) D1. Dances (Easy version) 思路: 对于 \(a\),它的头默认为 \(1\),则 \(a_0\) = \(1\) 对于排完序的 \(a\) 与 \(b\) 数组 最优为从 \(a\) 的结尾删除,从 \(b\) 的 ......
Codeforces version Dances Round Easy

「解题报告」Codeforces Round 905 (Div. 3)

A. Morning You are given a four-digit pin code consisting of digits from \(0\) to \(9\) that needs to be entered. Initially, the cursor points to the ......
Codeforces 报告 Round 905 Div

Codeforces Round 905 (Div. 2) C. You Are So Beautiful(数据结构)

Codeforces Round 905 (Div. 2) C. You Are So Beautiful 定义: 设数组 abcd 子数组定义:从原数组砍去前面若干元素,后边若干元素,剩余的数组。如:bc、ab 子序列定义:从原数组删除若干元素,剩余元素拼凑一起,组成的数组。如:ac、bd 思路: ......

Educational Codeforces Round 144(CF1796 D~E) 题解

D. Maximum Subarray 题目链接 十分钟秒了一道 *2000,非常爽,但是个人感觉确实非常简单。 下面令 \(b_i=a_{i}-x\),\(b_i'=a_i+x\) 。 因为 \(k<=20\),因此考虑一个复杂度与 \(k\) 相关的做法。 不妨 dp:设 \(f_{i,j,0/ ......
题解 Educational Codeforces Round 1796

Codeforces Round 905 (Div. 3)

E. Look Back 因为每次都是2,可以推出x<=y2^(n),转化成 x/y<=2^(n),求n直接取对数即可 注意: 1.答案很大要开LL 2.不要直接乘,会爆LL,直接利用原式即可,如果后面的大,就减去大多少的对数 3.记得向上取整 点击查看代码 #include<bits/stdc++ ......
Codeforces Round 905 Div

Codeforces Round 905 (Div. 2)

目录写在前面ABCD1/D2E写在最后 写在前面 比赛地址:https://codeforces.com/contest/1884 oonp 这场 div2 怎么才 2k5 人打啊我草 里面还不知道多少大神的小号,呃呃 打了 1k3 掉了 75 分也是牛逼 A 考虑如何拼出一个长度为 \(n-k\) ......
Codeforces Round 905 Div

Codeforces Round 905 - div.3(A B C D E)

目录Codeforces Round 905 (Div. 3)A. MorningB. Chemistry Codeforces Round 905 (Div. 3) A. Morning 模拟光标移动即可 void solve(){ string ss; cin >> ss; char ch = ......
Codeforces Round 905 div

Codeforces Round 904 (Div. 2)

目录写在前面ABCD写在最后 写在前面 比赛地址:https://codeforces.com/contest/1884 捏吗我不会容斥,我是飞舞。 A \(k\le 10\),于是直接枚举 \(x\sim x+20\) 检查即可。 // /* By:Luckyblock */ #include < ......
Codeforces Round 904 Div

Codeforces Round 905 Div 1 (CF1887)

A1. Dances (Easy version) 把 \(a,b\) 序列都从小到大排序,\(a\) 贪心删大的,\(b\) 贪心删小的,二分答案并 \(O(n)\) \(\text{check}\)。 Code ```cpp const int N=1e5+5; int T,n,m; int a ......
Codeforces Round 1887 905 Div

Codeforces Round 887 (Div. 2)

Codeforces Round 887 (Div. 2) A. Desorting 解题思路: 每次操作能使相邻数之差减\(2\),设最小相邻数之差为\(mind\),答案为\(ans = (mind + 1) / 2\)。 代码: #include <bits/stdc++.h> using n ......
Codeforces Round 887 Div

Codeforces Round 855 (Div. 3) C. Powering the Hero

有 \(n\) 张卡的卡堆,你可以自顶向下抽卡。装备卡显示数值为 \(a_i(a_i>0)\) ,英雄卡显示数值为 \(a_i = 0\) 。 如果是装备卡,你可以将卡抽出放在装备堆。如果是英雄卡,你可以将装备堆顶端的一张数值为 \(x\) 的装备卡装备给英雄,英雄数值 \(+ x\) 。无论是否装 ......
Codeforces Powering Round Hero 855

Codeforces Round 857 (Div. 2) B. Settlement of Guinea Pigs

你非常喜欢豚鼠。每个笼子可以住两只豚鼠,且你不想把每个笼子放入不同性别的豚鼠。豚鼠只有两种性别。假设你买到豚鼠时并不知道性别,只有医生能够分辨。 接下来的 \(n\) 天方案中,若第 \(i\) 天为 \(1\) ,你买入一只豚鼠;若为 \(2\) ,你请医生分辨你的豚鼠性别。 给出方案,你最少需要 ......
Codeforces Settlement Guinea Round Pigs

Educational Codeforces Round 145 (Rated for Div. 2) B. Points on Plane

给一个二维平面,你需要在上面放 \(n\) 个芯片。将一个芯片放在 \((x, y)\) 的代价为 \(|x| + |y|\) 。放 \(n\) 个代价的代价为,所有芯片中耗费的最大代价。并且你需要保证任意两个芯片之间的距离严格 \(> 1\) 。 现在给出 \(n\) 给芯片,询问放 \(n\) ......
Educational Codeforces Points Round Rated

Codeforces Round 875 (Div. 2) C. Copil Copac Draws Trees( DFS )

Codeforces Round 875 (Div. 2) C. Copil Copac Draws Trees 思路: 在输入树的边的同时记录他们的输入顺序 从 1 开始跑 DFS ,遇到未连上的边时 , 有两种情况(用 q 表示当前点的顺序序号) 1.边的顺序在这个点连上之前,那么 DFS 的 ......
Codeforces Round Copil Copac Draws

Educational Codeforces Round 149 (Rated for Div. 2)

这场D被切穿了。 A题 答案为 x 或者 x-1 1 B题 答案就是最长的连续一段的长度+1 证明的话大概可以将它看成是几段连续上升和下降的段,然后在峰谷、峰顶分别填上最小、最大,剩下的就依次递增或递减就行。 C题 将一段连续的0/1视作一个块,那么我们最小化这个块的数量就行。 D题如果猜到如果有解 ......
Educational Codeforces Round Rated 149

Codeforces Round 863 (Div. 3) B. Conveyor Belts

给一个 \(n \times n\) 的矩阵, \(n\) 是偶数。将矩阵按圈分割,同一圈的位置可以不消耗代价移动,可以消耗一个代价移动到相邻圈。 给出 \(n, x_1, y_1, x_2, y_2\) ,询问 \((x_1, y_1)\) 移动到 \((x_2, y_2)\) 的代价最小是多少。 ......
Codeforces Conveyor Belts Round 863

Codeforces Round 865 (Div. 2) B. Grid Reconstruction

给一个 \(2 \times n\) 的网格,且 \(n\) 是偶数。你需要将 \(1 \sim 2 \times n\) 填入这个网格。 一条路径是从 \((1, 1)\) 开始,每次只能向右或向下,到 \((2, n)\) 结束时,所经过的位置。按经过点的顺序标号,一两条路径的代价是 \(cos ......
Reconstruction Codeforces Round Grid 865

Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final Round)

\(D. Effects of Anti Pimples\) 对每个数字能到达的所有位置先预处理最大值,那么就代表选择这个数字之后真实的贡献,那么对这样的预处理值,最小值显然只有一种做法,为 \(2^0\) ,第二小的值应该可以与最小值一起选择,所以答案为 \(2^1\) ,以此类推之后,每个值乘上 ......
Round Codeforces COMPFEST Final based

Codeforces 选做

CF878E Numbers on the blackboard 好题。看到这个东西考虑打表一下最后每个点系数,需要一定的眼力才能看出相当于一个除了只有第一个是 1,后面的点每次最多比前面一个乘二的序列。知道结论证明就可以简单归纳了。 然后考虑答案的形态,发现如果我们称每次乘二的一段为连续段,那么对 ......
Codeforces

Codeforces Round 872 (Div. 2) B. LuoTianyi and the Table

给一个 \(n \times m\) 的矩阵和 \(n \times m\) 个数,你需要把这些数填入矩阵。保证 \[\sum_{i=1}^n \sum_{j=1}^m \left ( \mathop{max}\limits_{1 \leq x \leq i, 1 \leq y \leq j} a_ ......
Codeforces LuoTianyi Round Table 872

Codeforces Round 871 (Div. 4) D. Gold Rush

给一个堆 \(n\) 个石子,如果可以分裂为整数,它将分裂为 \(\frac{1}{3} n\) 和 \(\frac{2}{3} n\) 的两堆石子。并且新石堆会继续分裂。 询问过程中是否出现过大小为 \(m\) 的石堆。 显然记忆化 \(dfs\) 即可。 记忆数组一般开全局。容易观察到值域很大, ......
Codeforces Round Gold Rush 871