
CodeForces
文章平均质量分 59
Wa_Automata
这个作者很懒,什么都没留下…
展开
-
Codeforces Round 961 (Div. 2) C. Squaring
Ikrpprpp找到了一个由整数组成的数组a。他喜欢正义,所以他想要公平,也就是说,让它不递减。要做到这一点,他可以对数组的索引1≤i≤n执行一个公正的行为,它将用ai2替换ai(位置i的元素及其平方)。例如,如果a243353和ikrpprpp选择对i4执行正义行为,则a变为243953。使数组不递减所需的最少正义行为是多少?原创 2024-07-24 12:29:48 · 943 阅读 · 0 评论 -
Codeforces Round 905 (Div. 3)
# [Codeforces Round 905 (Div. 3)](https://codeforces.com/contest/1883)#### [Codeforces Round 905 (Div. 3) A. Morning](https://codeforces.com/contest/1883/problem/A)```javaimport java.io.*;public class Main { static BufferedReader bf = new Buffe原创 2023-11-09 16:21:15 · 203 阅读 · 0 评论 -
Codeforces Round 903 (Div. 3)
【代码】Codeforces Round 903 (Div. 3)原创 2023-10-31 17:43:01 · 148 阅读 · 0 评论 -
Codeforces Round 895 (Div. 3)
# [Codeforces Round 895 (Div. 3)](https://codeforces.com/contest/1872) ## [Codeforces Round 895 (Div. 3) A. Two Vessels](https://codeforces.com/contest/1872/problem/A)原创 2023-10-16 21:25:03 · 168 阅读 · 0 评论 -
Codeforces Round 900 (Div. 3)
# [Codeforces Round 900 (Div. 3)](https://codeforces.com/contest/1878)[Codeforces Round 900 (Div. 3) A. How Much Does Daytona Cost?](https://codeforces.com/contest/1878/problem/A)[Codeforces Round 900 (Div. 3) B. Aleksa and Stack](https://codeforces.com原创 2023-10-12 16:11:18 · 175 阅读 · 0 评论 -
Codeforces Round 898 (Div. 4)
【代码】Codeforces Round 898 (Div. 4)原创 2023-10-07 20:17:55 · 168 阅读 · 0 评论 -
Codeforces Round 442 (Div. 2) D. Olya and Energy Drinks
# [Codeforces Round 442 (Div. 2) D. Olya and Energy Drinks](https://codeforces.com/contest/877/problem/D)Note, that bfs can find right answer, but works in O(n·m·k). It's too slow.We'll store all not visited cells in set. For each row and column we'原创 2023-04-04 17:25:53 · 110 阅读 · 0 评论 -
Codeforces Round 859 (Div. 4) G. Subsequence Addition
# [Codeforces Round 859 (Div. 4) G1. Subsequence Addition (Easy Version)](https://codeforces.com/contest/1807/problem/G1)# [Codeforces Round 859 (Div. 4) G2. Subsequence Addition (Hard Version)](https://codeforces.com/contest/1807/problem/G2)假设一个序列里面有原创 2023-03-25 17:24:13 · 171 阅读 · 0 评论 -
Codeforces Round 859 (Div. 4) E. Interview
# [Codeforces Round 859 (Div. 4) E. Interview](https://codeforces.com/contest/1807/problem/E)#### Div4里面交互题,二分答案即可,第一次做出交互题,直接纪念一下原创 2023-03-25 17:13:01 · 187 阅读 · 0 评论 -
Codeforces Round 859 (Div. 4) D. Odd Queries
# [Codeforces Round 859 (Div. 4) D. Odd Queries](https://codeforces.com/contest/1807/problem/D)#### 将`[l,r]`的数字变成k,问整个数组的和是不是一个奇数。#### 使用前缀和维护即可。原创 2023-03-25 17:13:00 · 211 阅读 · 0 评论 -
Codeforces Round 859 (Div. 4) C. Find and Replace
# [Codeforces Round 859 (Div. 4) C. Find and Replace](https://codeforces.com/contest/1807/problem/C)#### 将一类字符变成0或者1,问是否能构造出0,1,0,或者1,0,1这种交互的字符串。#### 直接模拟即可,从左向右扫描一遍,遇见没有碰见过的字符标记成0,或者1,与前面异或即可,发生冲突直接返回`NO`原创 2023-03-25 17:07:43 · 166 阅读 · 0 评论 -
Codeforces Round #851 (Div. 2) E. Sum Over Zero
# [Codeforces Round #851 (Div. 2) E. Sum Over Zero](https://codeforces.com/contest/1788/problem/E)Denote $p$ as the prefix sum of $a$.For a segment $[x + 1,y]$ to be an element of $S$,$p_x ≤ p_y$ should be satisfied.Lets denote $dp_i$; as the maximum v原创 2023-03-01 16:46:49 · 311 阅读 · 0 评论 -
Codeforces Round #851 (Div. 2) D. Moving Dots
# [Codeforces Round #851 (Div. 2) D. Moving Dots](https://codeforces.com/contest/1788/problem/D)Let's think about the original problem where we do not think about subsets.We can easily observe that each dot does not change direction during moving.As原创 2023-03-01 16:35:09 · 393 阅读 · 0 评论 -
Codeforces Round #844 (Div. 1 + Div. 2, based on VK Cup 2022 - Elimination Round) D. Many Perfect S
# [Codeforces Round #844 (Div. 1 + Div. 2, based on VK Cup 2022 - Elimination Round) D. Many Perfect S](https://codeforces.com/contest/1782/problem/D)原创 2023-02-23 17:07:49 · 213 阅读 · 0 评论 -
Codeforces Round #849 (Div. 4) F. Range Update Point Query
# [Codeforces Round #849 (Div. 4) F. Range Update Point Query](https://codeforces.com/contest/1791/problem/F)###### 题目大意:- 给一串数字,有两个操作:- 操作1:将 $l-r$ 的数字,变成每位数字之和。- 操作2:求 $a_x$ 的数字。###### 解题思路:- 预处理每个数字的反转之后的类型,当数字之和为 $1$ 位数时,再次进行操作1就是本身- 我们通过 $BI原创 2023-02-08 00:12:20 · 317 阅读 · 0 评论 -
Codeforces Round #843 (Div. 2) D. Friendly Spiders
# [Codeforces Round #843 (Div. 2) D. Friendly Spiders](https://codeforces.com/contest/1775/problem/D)#### 题目:- $n(n原创 2023-01-29 16:00:42 · 409 阅读 · 0 评论 -
Codeforces Round #843 (Div. 2) C. Interesting Sequence
# [Codeforces Round #843 (Div. 2) C. Interesting Sequence](https://codeforces.com/contest/1775/problem/C)、#### 通过lowbit计算,对n进行增加,同时判断x在二进制下是不是n的子集,通过`and`,n只会越来越小,当n变成和x相等是,t也增加到了符合条件的情况。原创 2023-01-29 13:59:44 · 137 阅读 · 0 评论 -
Codeforces Round #843 (Div. 2) B. Gardener and the Array
# [Codeforces Round #843 (Div. 2) B. Gardener and the Array](https://codeforces.com/contest/1775/problem/B)The problem can be solved as follows: for each bit count the number of its occurrences in all numbers in the test. If each number has a bit which原创 2023-01-28 20:41:22 · 300 阅读 · 0 评论 -
Codeforces Round #843 (Div. 2) A. Gardener and the Capybaras
# [A1. Gardener and the Capybaras (easy version)](https://codeforces.com/contest/1775/problem/A1)# [A2. Gardener and the Capybaras (hard version)](https://codeforces.com/contest/1775/problem/A2)Consider five cases to solve the task:If the string star原创 2023-01-28 19:55:08 · 489 阅读 · 0 评论 -
Codeforces Round #805 (Div. 3) E. Split Into Two Sets
# [Codeforces Round #805 (Div. 3) E. Split Into Two Sets](https://codeforces.com/contest/1702/problem/E)Polycarp has $n$ dominoes, on each domino there are $2$ numbers — it turns out, there will be $2n$ numbers in total.We need to divide $2n$ numbers原创 2023-01-27 15:19:35 · 458 阅读 · 0 评论 -
Codeforces Round #842 (Div. 2) D. Lucky Permutation
# [Codeforces Round #842 (Div. 2) D. Lucky Permutation](https://codeforces.com/contest/1768/problem/D)#### 题目大意:给定一个数列,数字为1-n的全排列,可以交换任意两个数字,求至少交换多少次后,只存在一个逆序对。#### 解题思路:如果交换之后只在存在一个逆序对,那么这个逆序对的两个数字一定相邻。我们可以通过先通过并查集求出有多少个环,然后在这些存在的环当中是否有着相邻的数字,如果存在那么答案原创 2023-01-20 17:21:29 · 169 阅读 · 0 评论 -
Codeforces Round #842 (Div. 2) C. Elemental Decompress
# [Codeforces Round #842 (Div. 2) C. Elemental Decompress](https://codeforces.com/contest/1768/problem/C)Two cases produce no answers:- One element appears more than twice in $a$- After sorting, there is some index that $a[i]原创 2023-01-20 17:11:39 · 955 阅读 · 0 评论 -
Polynomial Round 2022 (Div. 1 + Div. 2, Rated, Prizes!) D. Same Count One
# [Polynomial Round 2022 (Div. 1 + Div. 2, Rated, Prizes!) D. Same Count One](https://codeforces.com/contest/1774/problem/D)Considering that we need to make the number of $1$s in each array the same, we should calculate the sum of $1$s, and every array原创 2022-12-18 11:20:24 · 684 阅读 · 1 评论 -
Educational Codeforces Round 139 (Rated for Div. 2) D. Lucky Chains
# [Educational Codeforces Round 139 (Rated for Div. 2) D. Lucky Chains](https://codeforces.com/contest/1766/problem/D)原创 2022-12-13 18:46:47 · 308 阅读 · 0 评论 -
Codeforces Round #837 (Div. 2) C. Hossam and Trainees
# [Codeforces Round #837 (Div. 2) C. Hossam and Trainees](https://codeforces.com/contest/1771/problem/C)- 对每个数字进行质因数分解,然后存到一个 $set$ 容器里面- 如果发现容器里面的数字有存在两个以上相同的质因数时,满足题意原创 2022-12-12 12:21:49 · 332 阅读 · 0 评论 -
Codeforces Round #835 (Div. 4) G. SlavicG‘s Favorite Problem
# [Codeforces Round #835 (Div. 4) G. SlavicG's Favorite Problem](https://codeforces.com/contest/1760/problem/G)Let's ignore the teleporting, and decide how to find the answer. Note that we don't need to ever go over an edge more than once, since going o原创 2022-11-23 17:38:41 · 568 阅读 · 0 评论 -
Codeforces Round #835 (Div. 4) F. Quests
# [Codeforces Round #835 (Div. 4) F. Quests](https://codeforces.com/contest/1760/problem/F)Let's fix $k$ and find the maximum number of coins we can get. Here we can do a greedy solution: at every step, we should always take the most rewarding quest. (I原创 2022-11-23 14:50:29 · 466 阅读 · 0 评论 -
Codeforces Round #835 (Div. 4) E. Binary Inversions
# [Codeforces Round #835 (Div. 4) E. Binary Inversions](https://codeforces.com/contest/1760/problem/E)Let's find out how to count the number of binary inversions, without flips. This is the number of $1$s that appear before a $0$. To do this, iterate th原创 2022-11-23 14:45:27 · 313 阅读 · 0 评论 -
Codeforces Round #835 (Div. 4) D. Challenging Valleys
# [Codeforces Round #835 (Div. 4) D. Challenging Valleys](https://codeforces.com/contest/1760/problem/D)One possible solution is to represent a range of equal element as a single element with that value. Construct this array $b$ and loop through it and原创 2022-11-23 14:42:01 · 372 阅读 · 0 评论 -
Codeforces Round #835 (Div. 4) C. Advantage
# [Codeforces Round #835 (Div. 4) C. Advantage](https://codeforces.com/contest/1760/problem/C)Make a copy of the array $s$: call it $t$. Sort $t$ in non-decreasing order, so that $t_1$ is the maximum strength and $t_2$ — the second maximum strength.Th原创 2022-11-23 14:19:38 · 347 阅读 · 0 评论 -
Codeforces Round #835 (Div. 4) B. Atilla‘s Favorite Problem
# [Codeforces Round #835 (Div. 4) B. Atilla's Favorite Problem](https://codeforces.com/contest/1760/problem/B)To solve the problem we need to find the character with the highest alphabetical order in our string, since Atilla will need at least that alph原创 2022-11-23 14:15:02 · 449 阅读 · 0 评论 -
Codeforces Round #835 (Div. 4) A. Medium Number
# [Codeforces Round #835 (Div. 4) A. Medium Number](https://codeforces.com/contest/1760/problem/A)Here are two ways to implement what's given in the problem: 1. Take input as an array $[a_1,a_2,a_3]$, and sort it. Output the middle element. 2. Write原创 2022-11-23 14:13:48 · 241 阅读 · 0 评论 -
Codeforces Round #834 (Div. 3) E. The Humanoid
# [Codeforces Round #834 (Div. 3) E. The Humanoid](https://codeforces.com/contest/1759/problem/E)Let's make two obvious remarks: 1. If we can absorb two astronauts with power $x≤y$, then we can always first absorb an astronaut with power $x$, and then原创 2022-11-20 14:28:57 · 339 阅读 · 0 评论 -
Codeforces Round #834 (Div. 3) D. Make It Round
# [Codeforces Round #834 (Div. 3) D. Make It Round](https://codeforces.com/contest/1759/problem/D)- 我的方法是 先求出当末尾 $1,2,3...$ 个 $0$ 的需要的倍数,然后在依次扩大,lcm就是求最小倍数的数字,然后再每次一倍倍加即可,但是发现 $long$ $long$ 并不能满足我的需求, $unsigned$ $long$ $long$ 即可。原创 2022-11-20 14:24:17 · 311 阅读 · 0 评论 -
Codeforces Round #834 (Div. 3) C. Thermostat
# [Codeforces Round #834 (Div. 3) C. Thermostat](https://codeforces.com/contest/1759/problem/C)First let's consider the cases when the answer exists:- If $a=b$, then the thermostat is already set up and the answer is $0$.- else if $|a−b|≥x$, then it原创 2022-11-20 14:13:49 · 241 阅读 · 0 评论 -
Codeforces Round #834 (Div. 3) A. Yes-Yes?
# [Codeforces Round #834 (Div. 3) A. Yes-Yes?](https://codeforces.com/contest/1759/problem/A)Note that it is enough to consider the string $full$=$YesYes...Yes$, where Yes is written $18$ times, since $18⋅3=54$, and our substring $s$ has size $|s|≤50$.原创 2022-11-20 14:11:11 · 178 阅读 · 0 评论 -
Codeforces Round #806 (Div. 4) F. Yet Another Problem About Pairs Satisfying an Inequality
# [Codeforces Round #806 (Div. 4) F. Yet Another Problem About Pairs Satisfying an Inequality](https://codeforces.com/contest/1703/problem/F)Call a pair good if it satisfies the condition. Let's split the inequality into three parts: $a_i < i$, $i原创 2022-11-18 22:36:08 · 272 阅读 · 0 评论 -
Codeforces Round #833 (Div. 2) B. Diverse Substrings
# [Codeforces Round #833 (Div. 2) B. Diverse Substrings](https://codeforces.com/contest/1748/problem/B)In a diverse string, there are at most $10$ distinct characters: '0', '1', $…$, '9'. Therefore, each of these characters can appear at most $10$ times原创 2022-11-13 11:08:39 · 410 阅读 · 0 评论 -
Codeforces Round #833 (Div. 2) C. Zero-Sum Prefixes
# [Codeforces Round #833 (Div. 2) C. Zero-Sum Prefixes](https://codeforces.com/contest/1748/problem/C)Let's consider the prefix sum array $s=[a_1,a_1+a_2,\ldots,a_1+a_2+\ldots+a_n]$.For every index $i$ such that $a_i=0$, if we change the value of $a_原创 2022-11-13 11:02:54 · 427 阅读 · 0 评论 -
Codeforces Round #790 (Div. 4) G. White-Black Balanced Subtrees
# [Codeforces Round #790 (Div. 4) G. White-Black Balanced Subtrees](https://codeforces.com/contest/1676/problem/G)Let's run a dynamic programming from the leaves to the root. For each vertex store the values of the number of balanced subtrees, as well原创 2022-11-10 22:15:15 · 221 阅读 · 0 评论