codeforces distance minimum maximum

Codeforces Round 680 (Div. 2, based on Moscow Team Olympiad) B. Elimination

一个比赛有一百人进入决赛,但是需要经过两轮初赛的选拔。初赛的最终结果由两场初赛产生,不幸的是初赛的最终排名被丢失了。 在每场初赛中,参赛者的排名按非升序排序。当两位参赛者的成绩一样,参赛编号更小的靠前。 现在只知道如下信息: 第一场初赛中,第一百名的成绩为 \(a\) 。且第一场初赛中前一百名的选手 ......
Elimination Codeforces Olympiad Moscow Round

Codeforces Round 685 (Div. 2) B. Non-Substring Subsequence

对于一个长为 \(n\) 的 \(01\) 字符串 \(s\) 有 \(n\) 个询问。第 \(i\) 个询问被 \(l_i, r_i\) 描述 \(1 \leq l_i < r_i \leq n\) 。 对于每个询问,你需要确定 \(s\) 中是否存在一个子序列等同于子串 \(s[l_i \cdo ......

Codeforces Round 690 (Div. 3) C. Unique Number

给一个正整数 \(x\) ,需要构造一个最小的正整数 \(n\) 使得 \(\sum digt(n) = x\) ,并且 \(\forall i \neq j, digt(n)_i \neq digt(n)_j\) 。 首先观察到 \(0\) 没有贡献,且会增加位数,所以不能有 \(0\) 。 由于 ......
Codeforces Number Unique Round 690

Codeforces Round 695 (Div. 2) A. Wizard of Orz

有 \(n\) 个数位板摆放成一条直线,每个数位板可以显示 \(0 \sim 9\) 的数字。最开始数位板显示的是 \(0\) 。每秒数位板上的数字都会加 \(1\) , \(9\) 的下一个数字是 \(0\) 。当一个数位板被暂停,它上面的数字将会定格在当前秒。 你必须对某个数位板执行一次暂停,在 ......
Codeforces Wizard Round 695 Div

CF1881F Minimum Maximum Distance

给定一棵树,树上的一些点被打上了标记,定义一个节点的贡献为其到所有标记节点距离的最大值,求最小贡献。 \(n \le 2 \times 10^5\)。 这道题的原题是 CF337D(甚至要更困难一些)。 很套路的换根 DP 啊。我们考虑设 \(f_i\) 为 \(i\) 子树内的标记节点到 \(i\ ......
Distance Minimum Maximum 1881F 1881

Codeforces Round 903 (Div. 3)

A. Don't Try to Count 解题思路 我们发现当 \(x.size() < s.size()\) 的时候,我们必须要让 \(x+=x\),当 \(x.size() \ge s.size()\) 的时候,我们只要此时判一下 \(x\) 中是否存在子串 \(s\),存在则马上输出答案,否 ......
Codeforces Round 903 Div

Educational Codeforces Round 156 (Rated for Div. 2) A-E

A题签到题 分余1 余2 余0讨论 #include<bits/stdc++.h> using namespace std ; #define maxn 400100 #define int long long int read(){ int ans = 0 , f = 1 ; char ch = ......
Educational Codeforces Round Rated 156

[AGC030F] Permutation and Minimum 题解

Permutation and Minimum 看到 300 的数据范围,再加上计数题,很容易就往计数 DP 方向去想。 为方便,我们将 \(n\) 乘二。 因为是两个位置取 \(\min\),于是我们便想到从小往大把每个数填入序列。于是DP数组第一维的意义便出来了:当前已经填入了前 \(i\) 小 ......
题解 Permutation Minimum 030F AGC

Maximums and Minimums (CF E)

思路: 分别求出 最小区间 和最大区间, 利用单调zai 处理即可 然后 在利用 调和级数 , 求最小值的倍数 后记: 为什么我不2个元素都求一个区间呢? ......
Maximums Minimums and CF

Codeforces Round 694 (Div. 2) A. Strange Partition

给一个长为 \(n\) 的数组 \(a\) 和一个正整数 \(x\) 。你可以执行以下操作任意次:用两个相邻元素的和替换这两个元素。如 \([\cdots, a_i,a_{i+1},\cdots] \rightarrow [\cdots, a_i + a_{i+1},\cdots]\) 。 一个数组 ......
Codeforces Partition Strange Round 694

Codeforces Round 697 (Div. 3) A. Odd Divisor

给一个正整数 \(n\) ,判断 \(n\) 是否存在一个 \(> 1\) 的奇数因子。 只要 \(n\) 的唯一分解下存在除 \(2\) 以外的质因子,则 \(n\) 存在 \(>1\) 的奇数因子。 于是 \(n \neq lowbit(n)\) 则 \(n\) 存在奇数因子。(应用了 \(2^ ......
Codeforces Divisor Round 697 Div

Codeforces Round 697 (Div. 3) B. New Year's Number

给出一个数 \(n\) ,询问能否存在 \(2020x + 2021y = n\) 。 对于方程 \(ax + by = n\) 可以直接解 \(exgcd\) 查询是否有解。 观察到 \(2020x + 2021y = n\) 可以化为 \(2020(x + y) + y = n\) 。不妨定为 ......
Codeforces Number Round Year 697

excel 导出 The maximum length of cell contents (text) is 32767 characters Excel单元格最大存储长度32767个字符,超长会报错,数据库中也有这个最大长度

excel 导出 The maximum length of cell contents (text) is 32767 characters 导出excel功能,报错。错误日志提示::The maximum length of cell contents (text) is 32767 chara ......
长度 32767 characters 字符 单元

[LeetCode] 2863. Maximum Length of Semi-Decreasing Subarrays_Medium tag: stack

You are given an integer array nums. Return the length of the longest semi-decreasing subarray of nums, and 0 if there are no such subarrays. A subarr ......

Codeforces Round 700 (Div. 2) B. The Great Hero

英雄卡初始存在 \(A\) 点力量值和 \(B\) 点生命值。有 \(n\) 张怪物卡,第 \(i\) 张怪物卡拥有 \(a_i\) 点力量和 \(b_i\) 点生命值。任意卡的生命值 \(\leq 0\) 则阵亡。 在任意一步中可以选择一张怪物卡与英雄卡决斗,战斗结束后双方各受到对方力量点数的伤害 ......
Codeforces Round Great Hero 700

Codeforces Round 703 (Div. 2) A. Shifting Stacks

给定 \(n\) 个石堆,第 \(i\) 个石堆高为 \(h_i\) 并且代表这堆石块的个数。在一次操作中你可以将第 \(i\) 堆中的一块石块移动(需要存在石块)到 \(i + 1\) 堆。询问是否可以使石堆的高度严格递增。 显然贪心地让第 \(1\) 堆的高度为 \(0\) 。 然后线性模拟使得 ......
Codeforces Shifting Stacks Round 703

Educational Codeforces Round 105 (Rated for Div. 2) A. ABC String

给一个长为 \(n\) 的字符串 \(a\) ,\(n\) 是偶数,字符串中只包含三种字符 \(A, B, C\) 。规定一个合法的字符串为一个符合入栈规则的字符串。 需要构造一个长为 \(n\) 的括号字符串 \(b\) 。 \(b\) 是一个合法的括号序列 \(\forall 1 \leq i ......
Educational Codeforces String Round Rated

Codeforces Round 899 (Div. 2)

目录写在前面ABCDE1E2写在最后 写在前面 比赛地址:https://codeforces.com/contest/1882。 你知道我要在这里放一首由日本女歌手演唱的歌曲: 一个队友去医院一个队友军训,堂堂单刷! 感觉开场 5h 太浪费了于是找了场 div2,然后 C 不会做卡了 1h,妈的。 ......
Codeforces Round 899 Div

CodeForces 1882E1 Two Permutations (Easy Version)

洛谷传送门 CF 传送门 考虑若是对一个排列进行操作,怎么做。 我们维护一个排列上的值域连续段 \([l, r]\),满足 \(a_{l + 1} = a_l + 1, a_{l + 2} = a_{l + 1} + 1\),以此类推。初始 \(l = r = 1\)。 那么我们每次可以选择往外扩充 ......
Permutations CodeForces Version 1882E1 1882E

CodeForces 1882E2 Two Permutations (Hard Version)

洛谷传送门 CF 传送门 如何评价,模拟赛搬了一道,前一天晚上代码写了一半的题。 考虑如何让操作次数最小。发现直接做太困难了。根本原因是,一次操作对序列的影响太大了。考虑做一些转化,减少一次操作对序列的影响。 仍然先考虑一个排列怎么做。 不知道为什么可以想到在排列前面添加特殊字符 \(0\) 变成 ......
Permutations CodeForces Version 1882E2 1882E

Codeforces Round 834 (Div. 3)

Codeforces Round 834 (Div. 3) A - Yes-Yes? 思路:判断每种情况即可 #include<bits/stdc++.h> using namespace std; //#define int long long //#define int __int128 #de ......
Codeforces Round 834 Div

Educational Codeforces Round 156 (Rated for Div. 2) - A B C D

目录A. Sum of Three A. Sum of Three 如果说给定的数为 n 如果 \(n \le 6\) 或 \(n = 9\) 时,无法分解 如果 $n %% 3 != 0 $ 时,可以 ......
Educational Codeforces Round Rated 156

Educational Codeforces Round 156 A-D

A. Sum of Three 思路1: 1.把数拆成1,2,n-3 2.如果(n-3)%3==0,那么拆成1,4,n-5,可证明n-3如果可被3整除,那么再左移两位一定除不尽 思路2: 1.如果n是奇数,那么可取一个数为2,其他两数为相邻数,如果两数其中一位被整除,那么两者往外走 2.如果n为偶, ......
Educational Codeforces Round 156 A-D

Educational Codeforces Round 156 (Rated for Div. 2)

Preface 沉迷Galgame不打CF懒狗闪总出列! 这场在大物课上口胡了前四个题,回去写了也都很顺,然后E题本来做不来的,看了眼昨天校队群里的消息就会做了 F题什么东西直接弃 A. Sum of Three 当\(n\bmod 3\ne 0\)时,用\((1,2,z)\)来凑;否则当\(n\b ......
Educational Codeforces Round Rated 156

Codeforces Round 706 (Div. 2) A. Split it!

给一个长度为 \(n\) 的字符串 \(s\) 。给定一个正整数 \(k\) 。询问 \(s\) 能否等于 \(a_1 + a_2 + \cdots + a_k + a_{k + 1} + R(a_k) + R(a_{k - 1}) + \cdots + R(a_{1})\) 。 其中 \(a_i\ ......
Codeforces Round Split 706 Div

Codeforces Round 707 (Div. 2, based on Moscow Open Olympiad in Informatics) B. Napoleon Cake

按以下 \(n\) 次操作制作蛋糕。 叠上第 \(i\) 块面包,然后浇上 \(a_i\) 单位的奶油。可以使当前往下 \(a_i\) 块面包沾上奶油。 输出空格隔开的 \(n\) 个数,第 \(i\) 个的 \(0/1\) 代表第 \(i\) 块面包是否沾有奶油。 比较显然的思路可以进行差分修改。 ......

Codeforces Round 834 (Div. 3)

A. Yes-Yes? #include <bits/stdc++.h> using namespace std; #define int long long using pii = pair<int, int>; using vi = vector<int>; const string T = " ......
Codeforces Round 834 Div

Educational Codeforces Round 109 (Rated for Div. 2) B. Permutation Sort

给一个长为 \(n\) 的排列 \(a\),你可以执行以下操作:选择一个子数组并且按任意顺序重排,但这个子数组不能是数组本身。 询问最少经过多少次操作可以使得排列 \(a\) 变为升序。 定义操作次数为 \(ans\) 。 若数组已经有序,\(ans = 0\) 。 若 \(a_1 = 1\) 或者 ......

Educational Codeforces Round 110 (Rated for Div. 2) Array Reodering

给一个长为 \(n\) 的数组 \(a\) 。 定义一对 \(pair(i, j)\) 是 \(good\) 的当且仅当 \(1 \leq i < j \leq n\) 且 \(gcd(a_i, 2 \cdot a_j) > 1\) 。 如果你可以以任意顺序重排数组 \(a\) ,找到最多的 \(g ......
Educational Codeforces Reodering Array Round

Codeforces Round 902 Div 1 (CF 1876)

A. Helmets in Night Light 按花费 sort 一下,\(b<p\) 就让他用 \(b\) 的花费告诉别人,剩下的人一开始用 \(p\) 的花费告诉即可。 B. Effects of Anti Pimples 发现一个数会被所有它的因数贡献,\(O(n\sqrt{n})\) 随 ......
Codeforces Round 1876 902 Div