You can use several words in query to find by all of them at the same time. In addition, if you are lucky search understands word forms and some synonyms. It supports search by title and author. Examples:

  • 305 — search for 305, most probably it will find blogs about the Round 305
  • andrew stankevich contests — search for words "andrew", "stankevich" and "contests" at the same time
  • user:mikemirzayanov title:testlib — search containing "testlib" in title by MikeMirzayanov
  • "vk cup" — use quotes to find phrase as is
  • title:educational — search in title

Results

1.
By Rhodoks, history, 4 years ago, In English
Codeforces Round #810 Editorial Sorry for the late editorial. May this editorial help you. If you have questions, feel free to ask. [problem:1711A] <spoiler summary="hint1."> The minimal weight is at least $1$ since $1$ divides any integer (so $1$ divides $p_1$). </spoiler> <spoiler summary="solution"> Since $k+1$ does not divide $k$, a permutation with weight equal to $1$ is: $[n,1,2,\cdots,n-1]$. </spoiler> <spoiler summary="code"> ~~~~~ #include <bits/stdc++.h> using namespace std; void work() { int n; cin>>n; cout<<n<<' '; for (int i=1;i<n;i++) cout<<i<<' '; cout<<endl; } int main() { int casenum=1; cin>>casenum; for (int testcase=1;testcase<=casenum;testcase++) work(); return 0; } ~~~~~ </spoiler> [problem:1711B] <spoiler summary="hint1."> See the party as a graph. </spoiler> <spoiler summary="hint2."> Divide the vertices into two categories according to their degrees' parity. </spoiler> <spoiler summary="solution"> Let's consider ...
$. You can calculate $a_j$ for all key positions $j$ using the difference array. Let $d^{1}_{j}=a_, $d^{2}_{x_i+1} \leftarrow d^{2}_{x_i+1}-2$, $d^{2}_{x_i+p_i+1} \leftarrow d^{2}_{x_i+p_i+1}+1$, $d^{2}_{x_i-p_i+1} \leftarrow d^{2}_{x_i-p_i+1}+1$, =0,d=0; LL lst=0; for (auto p:diff) { if (p.first!=lst) { a=a+(p.first-lst)*d, Let $d^{1}_{j}=a_{j}-a_{j-1}$, $d^{2}_{j}=d^{1}_{j}-d^{1}_{j-1}$, then the $i$-th day's rain will

Full text and comments »

  • Vote: I like it
  • +3132
  • Vote: I do not like it

2.
By MikeMirzayanov, history, 22 months ago, translation, In English
Предновогоднее обновление: подбор случайных задач для мэшапов Привет, Codeforces! Осталась всего пара дней до 2025 года. Напоследок в этом году залечу с обновлением &mdash; надеюсь, оно окажется полезным. Теперь в свой мэшап вы можете автоматически подбирать случайные задачи по ряду критериев и ограничений. Задачи берутся из архива, необычные задачи исключаются автоматически. Итак, нажимайте ссылку "Добавить случайные задачи" под списком задач и переходите к форме добавления. <center> <img style="zoom:75%;" src="/predownloaded/c0/ed/c0ed597ef33e0bcfdd5d7f24a473d1da873892a1.png"/> </center> Здесь можно: * исключить задачи, которые сдавали/пытались сдать/создали как авторы зарегистрированные на мэшап участники (чтобы задача была исключена, достаточно одного зарегистрированного участника, который её может знать), * если мэшап находится в группе (например, это группа ваших тренировок), то исключить все задачи из других контестов этой группы, * исключить задачи с подзадачами &mdash; такие задачи часто как-то связаны между собой и...
automatically; * "p D ratings:-1200 tags:greedy,dp": a problem with a difficulty level, contest letter assigned automatically; * "p D ratings:-1200 tags:greedy,dp": a, контесте назначается автоматически; * "p D ratings:-1200 tags:жадные алгоритмы,дп, > * "p D ratings:-1200 tags:жадные алгоритмы,дп" — задача с уровнем сложности не

Full text and comments »

  • Vote: I like it
  • +2609
  • Vote: I do not like it

3.
By maomao90, history, 3 years ago, In English
Hello 2024 Hello Codeforces, We are very glad to invite you to participate in [contest:1919], which will start on [contest_time:1919]. You will be given **8 problems** and **2.5 hours** to solve them. One of the problems will be divided into two subtasks. The round will be rated for everyone. There will be at most 2024 interactive problems, so please read the [guide for interactive problems](https://codeforces.me/blog/entry/45307) before the contest. All the problems are written and prepared by me. <spoiler summary="Spoiler"> The first tester tested on 10 October **2022**. </spoiler> We would like to give our sincere thanks to: - [user:errorgorn,2024-01-02] for his wonderful coordination! - [user:Alexdat2000,2024-01-02] for translating problem statements. - [user:dario2994,2024-01-02] for coming up with the solution to one of the problems. - [user:conqueror_of_tourist,2024-01-02], [user:iLoveIOI,2024-01-02], [user:Um_nik,2024-01-02], [user:oolimry,2024-01-02], [user:thenymphs...
: [user:tourist,2024-01-07] - C: [user:tourist,2024-01-07] - D: [user:tourist,2024-01-07] - E, ] - D: [user:tourist,2024-01-07] - E: [user:tourist,2024-01-07] - F1: [user:ko_osaga,2024-01-07

Full text and comments »

Announcement of Hello 2024
  • Vote: I like it
  • +2422
  • Vote: I do not like it

4.
By YouKn0wWho, 5 years ago, In English
Codeforces Round #735 (Div. 2) কি অবস্থা মামা? (That's Bengali for "What's up dude?") I am super excited to invite you to participate in [contest:1554] which will be held on [contest_time:1554]. This round is rated for future LGM participants whose current rating is $\le 2099$. You will be given $5$ problems and $2$ hours to solve them. All the problems are authored and prepared by me. I would like to thank - - [user:antontrygubO_o,2021-07-20] for his awe-inspiring coordination of the round <i style="color:White;"> and rejecting my problems, and thus hurting my feelings.</i> - [user:Um_nik,2021-07-20], [user:_Ash__,2021-07-25], [user:Anachor,2021-07-20], [user:Arg_007,2021-07-20], [user:Alpha_Q,2021-07-20], [user:DAleksa,2021-07-20], [user:steinum,2021-07-20], [user:tasdid,2021-07-20], [user:border,2021-07-20], [user:mk_Shahriar,2021-07-20], [user:t17,2021-07-20], [user:imAnik,2021-07-20], [user:Alfeh,2021-07-20], [user:Aritra741,2021-07-20], [user:FrozenBlood,2021-07-20], [user:SajidZakaria,2021-07-20]...
: [user:xiaofan7,2021-07-29], at $7$ mins! D: [user:6945930042DucLA,2021-07-29], at $7$ mins! , > C: [user:xiaofan7,2021-07-29], at $7$ mins! D: [user:6945930042DucLA,2021-07-29], at $7$ mins

Full text and comments »

  • Vote: I like it
  • +2167
  • Vote: I do not like it

5.
By Radewoosh, history, 8 years ago, In English
Hello 2019 Hello coders! I hope that you are enjoying the New Year as much as me. To make its beginning even greater, Codeforces is going to host a contest and I will be an author of all tasks. Hello 2019 will take place on [Friday](https://www.timeanddate.com/worldclock/fixedtime.html?day=4&month=1&year=2019&hour=17&min=35&sec=0&p1=166). Using the opportunity, I want to thank to: - [user:lewin,2019-01-02] and [user:mnbvmar,2019-01-02] for testing the round. - [user:mnbvmar,2019-01-02] for indescribably helpful discussions about problems. - [user:_kun_,2019-01-02] and [user:KAN,2019-01-02] for round coordination and help with preparation. - [user:MikeMirzayanov,2019-01-02] for such great platforms (you know which ones :P). The round will consist of 8 problems and you will be given <s>two and a half</s> three hours to solve them. Yes, the round will be **rated**. There will be no interactive problems, but if you want you can read [this](https://codeforces.me/blog/entry/45307) docum...
-05] - D: [user:rng_58,2019-01-05] (his personal task!) - E: [user:LHIC,2019-01-05] - F, : [user:Um_nik,2019-01-05] - D: [user:rng_58,2019-01-05] (his personal task!) - E: [user:LHIC,2019-01-05

Full text and comments »

Announcement of Hello 2019
  • Vote: I like it
  • +1910
  • Vote: I do not like it

6.
By Ashishgup, 6 years ago, In English
Codeforces Round #648 (Div. 2) Hi everyone! I would like to invite you to my fifth Codeforces Round, that I set with my friends [user:FastestFinger,2020-06-05], [user:Vivek1998299,2020-06-05] and [user:ridbit10,2020-06-05]. We are excited to bring another contest within a week :D With that said, I bring to your attention our new [contest:1365] that will take place on [contest_time:1365]. If your rating is less than **2100**, this round will be rated for you; otherwise, you can participate out of competition. I would really like to thank: - [user:FastestFinger,2020-06-05], [user:Vivek1998299,2020-06-05] and [user:ridbit10,2020-06-05] for helping with preparing problems and giving new ideas. - [user:300iq,2020-06-05] for coordinating our round. - [user:Um_nik,2020-06-06], [user:antontrygubO_o,2020-06-05], [user:ksun48,2020-06-05], [user:Jeel_Vaishnav,2020-06-05], [user:aryanc403,2020-06-05], [user:FlowerOfSorrow,2020-06-05], [user:KonaeAkira,2020-06-05], [user:_Aaryan_,2020-06-05], [user:Ari,2020-06-...
the contest :D, Good luck! :D, We are excited to bring another contest within a week :D

Full text and comments »

  • Vote: I like it
  • +2104
  • Vote: I do not like it

7.
By Ashishgup, 6 years ago, In English
Codeforces Round #646 (Div. 2) Hi everyone! I would like to invite you to my fourth Codeforces Round, which I have made with my friends [user:FastestFinger,2020-05-29] and [user:TheOneYouWant,2020-05-29]. In terms of problems, it is my favorite among all my rounds. With that said, I bring to your attention our new [contest:1363] that will take place on [contest_time:1363]. If your rating is less than **2100**, this round will be rated for you; otherwise, you can participate out of competition. I would really like to thank: - [user:FastestFinger,2020-05-29] and [user:TheOneYouWant,2020-05-29] for helping with preparing problems and giving new ideas. - [user:antontrygubO_o,2020-05-29] for coordinating our round - [user:300iq,2020-05-29], [user:Jeel_Vaishnav,2020-05-29], [user:Ari,2020-05-29], [user:aryanc403,2020-05-29], [user:mahmoudbadawy,2020-05-29], [user:Vivek1998299,2020-05-29], [user:Uzumaki_Narutoo,2020-05-30], [user:Bakry_,2020-05-31], [user:smartnj,2020-05-30] and [user:Nikhil_Medam,2020-05-29]...
explanation) — Hope you guys enjoyed the contest! :D, Good luck! :D

Full text and comments »

  • Vote: I like it
  • +2050
  • Vote: I do not like it

8.
By Radewoosh, history, 8 years ago, In English
Blogewoosh #1 Hello, codeforces! The community wants so the community gets it! :D Here it is, my very first blog about tasks and algorithms. At the beginning I've decided to post my entries on codeforces, maybe I'll switch to something different if it becomes uncomfortable. To pour the first blood I decided to choose a task from one of the old ONTAK camps. Task's name is "different words" ([you can submit here](https://szkopul.edu.pl/problemset/problem/wTy-sxQCIKry0Ml-6RvM0L78/site/?key=statement)). The statement goes as follows: You are given $n$ words ($2 \leq n \leq 50\,000$), every of length exactly $5$ characters. Each character can be a lowercase letter, an uppercase letter, a digit, a comma... basically, it can be any character with ASCII code between $48$ and $122$ (let's say that $k$ is the number of possible characters). A task is to find all pairs of indexes of words which are $\textbf{really different}$. Two words are $\textbf{really different}$ if they differ at all $5$ corres...
great to see a feedback from you. See you next time! :D, Hello, codeforces! The community wants so the community gets it! :D Here it is, my very first, The community wants so the community gets it! :D Here it is, my very first blog about tasks and

Full text and comments »

  • Vote: I like it
  • +1799
  • Vote: I do not like it

9.
By Error_Yuan, history, 3 years ago, In English
Goodbye 74TrAkToR + Problem A~E: The problems themselves are good and typical A~E. Indeed I like problem D. The pretest for A is a bit weak, and it's not a big problem yet. + Problem F: The problem has an origin. :) See the link: [click](https://www.luogu.com.cn/problem/P9394). The problem in contest is only a weakened version of the one in Luogu. + Problem G: It's said that our great coordinator had not proved the time complexity of the intended solution is correct :) If the authors did, please share it in the editorial. (although this problem is completely beyond my ability :) ) + Problem H: Oh dear [user:74TrAkToR,2023-12-30], could you please OEIS the sequence before you use the "several-integer-input" problem in rounds next time? Anyone who copied the first example and opened [https://oeis.org/A286331](https://oeis.org/A286331) could quickly get the formula. And the problem itself is not so hard imo. Anyway, it should not be used in contest, especially for the last problem. For me pers...
problems occurred in the round, but it feels like Div1A=B=C=D for me :( And actually the performance, + Problem A~E: The problems themselves are good and typical A~E. Indeed I like problemD. The

Full text and comments »

  • Vote: I like it
  • +1597
  • Vote: I do not like it

10.
By rng_58, history, 6 years ago, In English
AtCoder Library Recently, the number of algorithms and data structures we use in competitive programming are rapidly growing. It's a nice thing: by using more algorithms, the variety of possible problems gets wider, and we can enjoy more problems. On the other hand, before reaching adhoc, thinking-oriented part of this competition, we have to spend more and more time to learn algorithms. Sometimes a problem asks matching on general graphs; you have to find a paper describing it, read it, and implement its really complicated algorithm. Or sometimes you have to spend time tuning your library by a constant factor. Or sometimes you use multiple pre-written codes together, the variable names collide, and get annoyed. Until now, I basically rejected all problems that require pre-written codes of complicated algorithms because I don't like these things. For example, we never used segment trees with lazy propagation in our contests. However this way we can't use otherwise interesting problems and it ...
; using namespace atcoder; int main() { int n, m; scanf("%d %d", &n, &m); vector, int main() { int n, m; scanf("%d %d", &n, &m); vector a(n), b(m

Full text and comments »

  • Vote: I like it
  • +1385
  • Vote: I do not like it

11.
By Ashishgup, 6 years ago, In English
Codeforces Round #651 (Div. 2) Hi everyone! I would like to invite you to another one of our rounds, that I set with my friends [user:FastestFinger,2020-06-05], [user:smartnj,2020-06-19], [user:the_hyp0cr1t3,2020-06-19] and [user:ridbit10,2020-06-05]. The round [contest:1370] will take place on [contest_time:1370]. If your rating is less than **2100**, this round will be rated for you; otherwise, you can participate out of competition. I would really like to thank my co-setters and: - [user:isaf27,2020-06-05] for coordinating our round. - [user:cerberus97,2020-06-19], [user:Devil,2020-06-19], [user:Taran_1407,2020-06-19], [user:Alireza_Keshavarz,2020-06-19], [user:Vivek1998299,2020-06-19], [user:KonaeAkira,2020-06-19], [user:demoralizer,2020-06-19], [user:Dragnoid99,2020-06-19], [user:agtxdy,2020-06-19], [user:Rajdeep,2020-06-19], [user:aryanc403,2020-06-19], [user:lavish315,2020-06-19], [user:DeadlyCritic,2020-06-19], [user:Utkarsh.25dec,2020-06-19], [user:AmShZ,2020-06-19], [user:_Aaryan_,2020-06-19]...
problems interesting :D, Good luck! :D

Full text and comments »

  • Vote: I like it
  • +1654
  • Vote: I do not like it

12.
By zscoder, history, 6 years ago, In English
[Tutorial] Generating Functions in Competitive Programming (Part 1) Hi everyone! Inspired by the recent [Codeforces Round 641](https://codeforces.me/contest/1349), I decided to write an introductory tutorial on generating functions here. I am by no means an expert in generating functions so I will write about what I currently know about them. [user:MiFaFaOvO,2020-05-15] has written a really interesting [blog](https://codeforces.me/blog/entry/76447) here on Codeforces about more advanced applications of generating functions, but I think there is no English tutorial on the basics of this topic yet (or at least on CP sites). Thus, I would like to share about this topic here. I plan to split this tutorial into two parts. The first part (this post) will be an introduction to generating functions for those who have never learned about them at all, and some standard examples and showcases of generating functions. The second part will be a collection of several applications of generating functions in CP-style problems. If you are already familiar with ge...
as **deck enumerator**) $D(x) = \displaystyle\sum_{n \ge 1}\frac{x^{n}}{n!}$. What is $D(x)^{k}$? We, enumerator**) $D(x) = \displaystyle\sum_{n \ge 1}\frac{x^{n}}{n!}$. What is $D (x)^{k}$? We have $[x^{n}]D, of **undirected** cycles of length $n$ and $D(x)$ denote its EGF. Then, $D(x) = \displaystyle\sum_{n, ) = \exp(D(x))$, so we get the formula $G(x) = \exp\left(\ln\left(\sqrt{\frac{1}{1-x}}\right) - \frac{x}{2, Finally, let $d_{n}$ be the number of bipartite graphs on $n$ vertices and $D (x)$ be its EGF. Then, Rearranging gives us $\frac{f(n,k)}{n!} = \frac{[x^{n}]D(x)^{k}}{k!}$. Hence, $\displaystyle\sum_{n, Thus, we have the simple formula $H(x,y) = \exp(D(x)y)$. Note that $D(x) = \displaystyle\sum_{n \ge

Full text and comments »

  • Vote: I like it
  • +1299
  • Vote: I do not like it

13.
By errorgorn, 6 years ago, In English
Codeforces Raif Round 1 [Div. 1 + Div. 2] Hello, Codeforces! Welcome to the [contest:1428] supported by Raiffeisenbank, that will start on [contest_time:1428]. **It will be a combined rated round for both divisions. Note that the start time is unusual.** All problems were authored and prepared by [user:bensonlzl,2020-10-15], [user:oolimry,2020-10-15], [user:errorgorn,2020-10-15], [user:dvdg6566,2020-10-15], [user:shenxy13,2020-10-15]. [user:Ari,2020-10-15] gato to: - [user:isaf27,2019-05-10] and [user:KAN,2020-10-15] for round coordination and help with preparation - [user:zhangguangxuan99,2020-10-15] for being epic IOI trainer <3 - Our army of testers: [user:Ari,2020-10-15], [user:KAN,2020-10-15], [user:Monogon,2020-10-15], [user:Prabowo,2020-10-15], [user:SYY,2020-10-15], [user:SleepyShashwat,2020-10-15], [user:TeaTime,2020-10-15], [user:Tlatoani,2020-10-15], [user:_rs_,2020-10-15], [user:agul,2020-10-15], [user:cstuart,2020-10-15], [user:dantoh,2020-10-15], [user:jhkoh,2020-10-15], [user:kai824,2020-10-15]...
:300iq,2020-10-17] B: [user:icecuber,2020-10-17] C: [user:Not-Afraid,2020-10-17] D, D: [user:Radewoosh,2020-10-17]

Full text and comments »

  • Vote: I like it
  • +1254
  • Vote: I do not like it

14.
By EvenImage, history, 7 years ago, In English
A problem collection of ODE and differential technique ##A problem collection of ODE and differential technique *This problem might be well-known in some countries, but how do other countries learn about such problems if nobody poses them.* For those who are interested in well-known problems in China. Thank [user:Elegia,2020-04-23] and [user:djq_cpp,2020-04-23] for developing this technique. Thank [user:tEMMIE.w.,2020-04-23] for reviewing this article. ####[Chain Reaction](http://uoj.ac/problem/50) in UOJ Round 3 By [user:vfleaking,2020-04-23] **Statement** ​ You are given a set $A$, you need to compute $g_{i} = \frac{1}{2} \sum_{j,k}{i-1 \choose j}{i-1-j \choose k} g_jg_k$ where $i-1-j-k \in A$. **Solution** ​ Let the EGF of $g$ be $x(t)$ and EGF of $A$ be $a(t)$. Thus $x'(t)=\frac{1}{2} a(t) x^2(t)+1$. We can solve this equation by D&C and FFT in $O(n\log^2 n)$. But there is a <s>slower</s> solution in $O(n\log n)$. ​ For a polynomial equation $f(x(t))=0$, we can use the Newton's method to solve it. If we find ...
$n\leq 10^9, k\leq 2000, d=6$, Combined with Newton's method, we can compute the composition inverse of a D -finite series. A, Compute $\frac{n!}{2^d} [x^n]\sum_{p=0}^{k} {m \choose p} (e^x-e^{-x})^p (e^x+e^{-x})^{m-p}$., Compute the sum of $\frac{n!}{\prod_{i=1}^k x_i!}$ where $\sum_{i=1}^k x_i=n$ and $d|x_i$ for all, For an ODE $\frac{d}{dt} x =f(x)$, we have, It is known that every algebraic generating function is D-finite, and the coefficient is P, The EGF of each term is $\sum_{j\geq 0} \frac{x^{jd}}{(jd)!}=\frac{1}{d }\sum_{j=0}^{d-1} e, The right is P-recursive, thus $Q$ can be computed in $O(m)$. So the answer is $\frac{n!}{2^d} [x, \frac{d}{dx} +b_i) g_{i-1}(x)$. Let $P(x) = \prod_{i=1}^n (x+b_i)=\sum_{k=0}^n p_k x^k$. Then $g_n, can solve this equation by D&C and FFT in $O(n\log^2 n)$. But there is a slower solution in, this equation by D&C and FFT in $O(n\log^2 n)$. But there is a slower solution in $O(n\log n, $$\begin{eqnarray*} \frac{d}{dt} x_{2n} &\equiv & f(x_n) + f'(x_n) (x_{2n}-x_n) \pmod {t^{2n, $$\begin{eqnarray*} \left(\frac{d}{dt} x_{2n}\right)r &\equiv & (f(x_n)-f'(x_n) x_n) r + f'(x_n, $-th term, we have $\sum_{d|n} f'(d) g(\frac{n}{d})=\frac{1}{k} \sum_{d|n} f(d) g'(\frac{n}{d, $. Since it's D-finite, the dimension of $V_w$ is finite., ))$ when $F$ is D-finite. We can construct the ODE of $F(G(x))$ and solve the equation usingD&C and, ,b}$ effectively. Since $1$ and $\omega$ are independent, we can regard $\frac{1}{d}\sum_{j=0}^{d-1, - If $u \in \mathcal{D}$, $v$ is algebraic and $v(0)=0$, then $w=u(v(x)) \in \mathcal{D}$, - If $u,v \in \mathcal{D}$, then $w=au+bv \in \mathcal{D}$, $\dim V_w \leq \dim V_u+\dim V_v$, - If $u,v \in \mathcal{D}$, then $w=u * v \in \mathcal{D}$, $\dim V_w \leq \dim V_u\dim V_v$, $u* v, - If $u,v \in \mathcal{D}$, then $w=uv \in \mathcal{D}$, $\dim V_w \leq \dim V_u\dim V_v$, . So we can use D&C and FFT to solve this equation in $O(n\log^2 n)$.

Full text and comments »

  • Vote: I like it
  • +1044
  • Vote: I do not like it

15.
By Enchom, 12 years ago, In English
Who sorry_dreamoon really is Hello everybody. So I was really bored tonight and looked at so many comments being like "[user:sorry_dreamoon,2015-02-18] is X" and then people arguing and disagreeing. Since I had nothing better to do, I decided to finally unravel the truth of who he actually is. Here is the full case and how I actually got to him, hope you enjoy! :D Selection ------------------ Let's start by the obvious. He managed to get first place in Div2 and he got second in Div1 (would've been first if the scores were static). So what we know is that he is really good. Let's look at the past 10 Div1 contests. It turns out that only 8 times it happened that someone with a rating of less than 2500 got in top5. This is 8 times out of 50 people being in top5. But he was second and almost first, so he is better than that. It turns out actually, that in the past 10 Div1 contests, only 2 times it happened that someone with rating less than 2500 got in top3. Combining this information with [user:sorr...
actually got to him, hope you enjoy! :D, sleep better at night :D

Full text and comments »

  • Vote: I like it
  • +1383
  • Vote: I do not like it

16.
By Radewoosh, history, 8 years ago, In English
Blogewoosh #6 Hello, codeforces! Sorry for the long break, but the last weeks of holidays and the first weeks of academic year took my attention. I hope today's trick will make you forgive me. :P I invented this trick a few years ago, but for sure I wasn't first, and some of you already know it. Let's consider the following **interactive** task. There are $n$ ($1 \leq n \leq 10^5$) hidden integers $a_i$, each of them from range $[1, 10^{18}]$. You are allowed to ask at most $103000$ queries. In one query you can choose two integers $x$ and $y$ ($1 \leq x \leq n, 1 \leq y \leq 10^{18}$) and ask a question ''Is $a_x \geq y$?'' The task is to find the value of the greatest element in the hidden array. The checker **isn't** adaptive. Unfortunately, this task is only theoretical, and you cannot solve it anywhere, but it'll turn out, that solution can be handy in many other, much more complicated problems. [cut] $ $ Even beginners should be able to quickly come up with a solution which ask...
$O(log(n))$ times! A total number of queries will be equal to $n+O(log(n) \cdot log(d))$, which, asks $n \cdot log(d)$ queries (where $d = 10^{18}$). Unfortunately, this is definitely too much. The, be solved with this trick, share them in the comments. See you next time! :D, each element if it's greater than $\lceil \frac{d}{2} \rceil$, or something, then forget about, without shuffling sources. Why? Test cases were weak. :D, . Here comes an idea: let's iterate over numbers in the hidden array like in the $n \cdot log(d, Even beginners should be able to quickly come up with a solution which asks $n \cdot log(d

Full text and comments »

  • Vote: I like it
  • +1075
  • Vote: I do not like it

17.
By McDic, history, 7 years ago, In English
Codeforces Round #589 (Div. 2) **다시 만나서 반가워요, 코드포스!** (Nice to see you again, Codeforces!) I'm again happy to introduce you to [Codeforces Round #589 (Div. 2)](https://codeforces.me/contests/1228). Please look at following information for details: - This contest will take place on [contest_time:1228]. - The round will be **rated for all Division 2 participants**. - There are **6 problems** and you will have **2 hours** to solve them. Score distribution will be announced later. The listed handles below are contributors. Thank you for all who listed! - **Main author**: ~McDic,2019-09-26 &mdash; I made and prepared all problems. - **Coordinator**: ~arsijo,2019-09-26 &mdash; He is my coordinator again. - **Early phase testers**: ~dorijanlendvaj,2019-09-26 ~tfg,2019-09-26 ~Lawali,2019-09-26 &mdash; They are early phase testers. They mostly focused on test data. - **Late phase testers**: ~_Kuroni_,2019-09-26 ~imbr92,2019-09-26 ~Redux,2019-09-26 ~Dr_Park,2019-09-26 ~Mahotsukai,2019-09-26 ~TOPWINDFLOWER,20...
appeared in another Div.1 contest. 3. Scoring distribution is **500(A)-1000(B)-1250(C)-1750(D)-2250, distribution is **500(A)-1000(B)-1250(C)-1750(D)-2250(E)-2750(F)**. 4. Editorial: https://codeforces.com

Full text and comments »

  • Vote: I like it
  • +1581
  • Vote: I do not like it

18.
By platelet, 3 years ago, In English
CodeTON Round 5 (Div. 1 + Div. 2, Rated, Prizes!) **Note the unusual start time of the round.** Hello, Codeforces! Now that Gaokao is over, we are very glad to invite you to participate in [contest:1842], which will start at [contest_time:1842]. You will be given **9 problems** and **3 hours** to solve them. The round will be rated for everyone. All problems are written and prepared by [user:Gary2005,2023-06-21], [user:Asuka,2023-06-21], [user:Crying,2023-06-21], [user:sjcsjcsjc,2023-06-21], [user:MonkeyKing,2023-06-21], [user:DerekFeng,2023-06-21], [user:KbltQaQ,2023-06-21], [user:ShmilyTY,2023-06-21] and me. Statements and editorials will be available in Chinese (Simplified) after the contest. We would like to give our sincere thanks to: - [user:errorgorn,2023-06-21] for his wonderful coordination! - [user:Alexdat2000,2023-06-21] for translating problem statements. - [user:gyh20,2023-06-21], [user:wangziji,2023-06-21], [user:flowerletter,2023-06-21], [user:themoon,2023-06-21], [user:qiuzx,2023-06-21], [user:Gezh...
: [user:alexwice,2023-06-25] B: [user:ksun48,2023-06-25] C: [user:PinkieRabbit,2023-06-25]D, ] D: [user:Um_nik,2023-06-25] E: [user:Qingyu,2023-06-25] F: [user:amenotiomoi,2023-06-25

Full text and comments »

  • Vote: I like it
  • +1345
  • Vote: I do not like it

19.
By McDic, history, 7 years ago, In English
Codeforces Round #633 **내가 돌아왔다!** (Hello, Codeforces!) I am thrilled to introduce you to [Codeforces Round #633](https://codeforces.me/contests/1338,1339). Followings are basic information: - This contest will take place on [contest_time:1338]. - The round is **rated for all participants** who can understand this announcement. There will be two divisions. - There are **5 problems** in each division and you will have **2 hours** to solve it. - Score distribution will be announced later. Followings are contributors: - **Authors**: [user:McDic,2020-04-10] (All Div.2 problems and Div.1 D), [user:tzuyu_chou,2020-04-10] (Div.1 E) - **Coordinator**: [user:antontrygubO_o,2020-04-10] - **Testers**: - **Phase 1** (When this round was supposed to be Div.2): [user:dorijanlendvaj,2020-04-10], [user:SoulTch,2020-04-10], [user:pajenegod,2020-04-10], [user:AryaPawn,2020-04-10], [user:Rahul,2020-04-10], [user:mcdx9524,2020-04-10], [user:300iq,2020-04-10], [user:Nemo,2020-04-10], [user:tfg,2020-04-10]...
contributors: - **Authors**: [user:McDic,2020-04-10] (All Div.2 problems and Div.1D, - **Authors**: [user:McDic,2020-04-10] (All Div.2 problems and Div.1 D), [user:tzuyu_chou,2020-04

Full text and comments »

  • Vote: I like it
  • +1622
  • Vote: I do not like it

20.
By shashwatchan, history, 6 years ago, In English
Codeforces Round #663 (Div. 2) Henlo Codeforces! ^_^ I invite you to participate in [Codeforces Round #663 (Div.2)](https://codeforces.me/contests/1391) taking place on [contest_time:1391]. The round is rated for users rated less than 2100, while other users can participate non-competitively. The round features five problems, and you have 2 hours to solve them. There may, or may not, be an interactive problem; regardless, you should [know](https://codeforces.me/blog/entry/45307) how to deal with them. I would, now, like to thank– - [user:antontrygubO_o,2020-07-31] for coordination <s>and manipulation</s>. - [user:AwakeAnay,2020-07-31], [user:AsleepAdhyyan,2020-07-31], and [user:RestingRajarshi,2020-07-31] for always listening to my problem ideas. - [user:BRCode,2020-08-03] for making [3b1b-style](https://www.youtube.com/watch?v=LYrtRnz35sU) video editorials of the problems! - [user:Aggu_01000101,2020-08-07], [user:Devil,2020-07-31], [user:Dragnoid99,2020-07-31], [user:NOOBxCODER,2020-07-31], [use...
) - [Problem D](https://www.youtube.com/watch?v=kspzot42-uI) - [Problem E](https://www.youtube.com/watch?v, ://www.youtube.com/watch?v=vWHUmtiPRQw) - [Problem D ](https://www.youtube.com/watch?v=kspzot42-uI) - [Problem E

Full text and comments »

  • Vote: I like it
  • +1305
  • Vote: I do not like it

21.
By Ashishgup, 6 years ago, In English
Codeforces Round #685 (Div. 2) Hi everyone! I would like to invite you to another one of our rounds, that I set with my friends [user:Jeel_Vaishnav,2020-11-19], [user:FastestFinger,2020-11-19], [user:Utkarsh.25Dec,2020-11-19], [user:the_hyp0cr1t3,2020-11-19] and [user:ridbit10,2020-11-19] We had two approved contests, but decided to merge it into one with more logical thinking ^_^ The round [contest:1451] that will take place on [contest_time:1451]. If your rating is less than **2100**, this round will be rated for you; otherwise, you can participate out of competition. I would really like to thank my co-setters and: - [user:300iq,2020-06-05] for coordinating our round and always replying quickly. - [user:jtnydv25,2020-11-19], [user:antontrygubO_o,2020-11-20], [user:Monogon,2020-11-19], [user:Vivek1998299,2020-11-19], [user:tejas10p,2020-11-19], [user:smit_mandavia,2020-11-19], [user:T1duS,2020-11-20], [user:kshitij_sodani,2020-11-20], [user:ayushsinghiitr,2020-11-19], [user:Ajax,2020-11-19], [user:...
**UPD 3:** Congratulations to the winners! :D, Good luck — let the games begin :D

Full text and comments »

  • Vote: I like it
  • +1117
  • Vote: I do not like it

22.
By -is-this-fft-, history, 5 years ago, In English
Self-deception: maybe why you're still grey after practicing every day I generally don't like to give much advice on "how to practice", but recently I have been thinking a lot about this and I realized that there is something that I believe affects a lot of people (though it is admittedly hard to tell) that barely gets talked about: self-deception. Self-deception is a devious thing. It can be very hard to detect, yet can be fatal to improvement. This blog is mainly directed to greys, greens and cyans that can't get out of these categories. Most examples are given with that in mind. That being said, I believe others have something to think about as well. This is my first blog on such "psychological issues" and I don't know if I'll ever make another one. It's certainly a difficult topic to write about because for most of the blog, the message is "your practice is not as good as you think it is" or even "you aren't as good as you think you are" which can of course be a hard thing to hear. Thus, I have to somehow be very gentle while getting the poin...
based on the position in the contest (like "Div.1 D") used to only show one problem. Sadly, they don't

Full text and comments »

  • Vote: I like it
  • +1292
  • Vote: I do not like it

23.
By wangmarui, history, 10 months ago, In English
Hello 2026 Happy new year, Codeforces! We are glad to invite you to take part in [contest:2183], which will start on [contest_time:2183]. You will be given **9 problems** and **3 hours** to solve them. **At least one problem will be interactive**, so please make sure to read the [guide for interactive problems](https://codeforces.me/blog/entry/45307) before the contest. This round is open and rated for everyone. Problems are authored by [user:wangmarui,2025-12-23], [user:Gold14526,2025-12-23], [user:Hoks_,2025-12-23], [user:Neil_Qian,2025-12-23], [user:Network_Error,2025-12-23], [user:jiazhichen844,2025-12-23] and [user:xvchongyv,2025-12-23]. We would like to thank: - [user:Um_Nik,2025-12-23] for pre-reviewing the round. - [user:Proof_by_QED,2025-12-23] for his wonderful coordination. - [user:Alexdat2000,2025-12-23] for Russian translation. - [user:Geothermal,2025-12-23], [user:StarSilk,2025-12-23], and [user:Dominater069,2025-12-23] for nutella testing. - [user:Mindeve...
Update 2: Hacks will be disabled on problems A-D.

Full text and comments »

Announcement of Hello 2026
  • Vote: I like it
  • +1039
  • Vote: I do not like it

24.
By arsijo, 7 years ago, translation, In English
Технокубок 2020 — Отборочный Раунд 1 (и открытые рейтинговые раунды Codeforces Round 591 Div.1, Div.2) Добрый день! <p><a style="float:right;margin:0 0 1em 1em;" href="http://codeforces.me/technocup2020"><img src="http://assets.codeforces.com/images/technocup-narrow-logo.png"/></a> В [contest_time:1223] состоится <a href="/contests/1223">Отборочный Раунд 1</a> олимпиады для школьников <a href="http://codeforces.me/blog/entry/70187">Технокубок 2020</a>. Раунд будет длиться два часа, участникам будут предложены 7 задач. По его результатам лучшие участники (но не более 45% от общего числа участников раунда) будут приглашены на финальный этап в Москву. Для регистрации на раунд и участия перейдите <a href="http://codeforces.me/contests/1223">по ссылке</a>. Не забудьте заранее зарегистрироваться на раунд! Для опоздавших будет открыта дополнительная регистрация. <p style="text-align:center"> <a style="font-size:20px;" href="http://codeforces.me/contests/1223">Зарегистрироваться на Отборочный Раунд 1 &rarr;</a> <br/> <small>Соревнование открыто для всех в виде отдельных ...
:3195513], [submission:3794163] | | D | D | [submission:5482410], [submission:2060057] | | Go | Go, ], [submission:3794163] | | D | D | [submission:5482410], [submission:2060057] | | Go | Go

Full text and comments »

  • Vote: I like it
  • +1254
  • Vote: I do not like it

25.
By HosseinYousefi, 12 years ago, In English
C++ Tricks I see lots of programmers write code like this one: ~~~~~ pair<int, int> p; vector<int> v; // ... p = make_pair(3, 4); v.push_back(4); v.push_back(5); ~~~~~ while you can just do this: ~~~~~ pair<int, int> p; vector<int> v; // ... p = {3, 4}; v = {4, 5}; ~~~~~ [cut] [This](http://codeforces.me/blog/entry/10124) is a great C++11 tutorial for those who want to know more about C++11. #### 1. Assign value by a pair of {} to a container I see lots of programmers write code like this one: ~~~~~ pair<int, int> p; // ... p = make_pair(3, 4); ~~~~~ while you can just do this: ~~~~~ pair<int, int> p; // ... p = {3, 4}; ~~~~~ even a more complex `pair` ~~~~~ pair<int, pair<char, long long> > p; // ... p = {3, {'a', 8ll}}; ~~~~~ What about `vector`, `deque`, `set` and other containers? ~~~~~ vector<int> v; v = {1, 2, 5, 2}; for (auto i: v) cout << i << ' '; cout << '\n'; // prints "1 2 5 2" deque<vector<pair<in...
deque>> d; d = {{{3, 4}, {5, 6}}, {{1, 2}, {3, 4}}}; for (auto i: d

Full text and comments »

  • Vote: I like it
  • +971
  • Vote: I do not like it

26.
By dario2994, 6 years ago, In English
Codeforces Global Round 11 <img src="/predownloaded/2e/e2/2ee2f0f95f05aae6ca6f47812dae2dc2aabf277b.png" style="width:200px; float:right; margin: 0 1em 1em 1em"/> Hi! On [contest_time:1427] we will host [contest:1427]. This is the fifth round of the 2020 series of [Codeforces Global Rounds](https://codeforces.me/blog/entry/65002). The rounds are open and rated for everybody. The prizes for this round are as follows: - 30 best participants get a t-shirt. - 20 t-shirts are randomly distributed among those with ranks between 31 and 500, inclusive. The prizes for the 6-round series in 2020: - In each round top-100 participants get points according to the [table](https://pastebin.com/QT5sXEaT). - The final result for each participant is equal to the sum of points he gets in the four rounds he placed the highest. - The best 20 participants over all series get sweatshirts and place certificates. Thanks to XTX, which in 2020 supported the global rounds initiative! Problems for this round ar...
The low scores for problems B-C-D-E-F-G should not suggest that they are easier than usual

Full text and comments »

Announcement of Codeforces Global Round 11
  • Vote: I like it
  • +1025
  • Vote: I do not like it

27.
By Radewoosh, history, 8 years ago, In English
Blogewoosh #2 Hello, codeforces! All signs in the sky and on the ground indicate that you've enjoyed my first blog, so here is the second one. I've decided to choose a Polish task again, as there are plenty of interesting ones. This time we'll take a look at the "plot purchase" ([you can submit here](https://szkopul.edu.pl/problemset/problem/hwbyoUkNFPXQLOPcw3x5huTR/site/?key=statement)), which is a bit easier, but a few years ago I was very proud of myself when I solved it. The statement goes as follows: You are given a square $n \times n$ grid ($1 \leq n \leq 2000$). In every cell, there is a number from the range $[1, 2 \cdot 10^9]$. You are also given an integer $k$ ($1 \leq k \leq 10^9$). A task is to find a subrectangle of this grid such that the sum of values in this subrectangle lies in the range $[k, 2\cdot k]$ (or report that there is no such subrectangle). Just print coordinates of its opposite corners. [cut] $ $ If the problem would be more difficult, and we'd be asked to fi...
about it. See you next time! :D

Full text and comments »

  • Vote: I like it
  • +838
  • Vote: I do not like it

28.
By -is-this-fft-, history, 5 years ago, In English
[Tutorial] Collection of little techniques #### Introduction There are a number of "small" algorithms and facts that come up again and again in problems. I feel like there I have had to explain them many times, partly because there are no blogs about them. On the other hand, writing a blog about them is also weird because there is not that much to be said. To settle these things "once and for all", I decided to write my own list about about common "small tricks" that don't really warrant a full tutorial because they can be adequately explained in a paragraph or two and there often isn't really anything to add except for padding. This blog is partly inspired by [user:adamant,2022-03-15]'s [blog](48417) from a few years ago. At first, I wanted to mimic adamant's blog structure exactly, but I found myself wanting to write longer paragraphs and using just bolded sentences as section headers got messy. Still, each section is short enough that it would not make much sense to write separate blogs about each of these things. A...
)$) entirely covers the bar chart, so we must have $$\displaystyle H_n \le \int_0^n f(x) \, \mathrm{d} x

Full text and comments »

  • Vote: I like it
  • +804
  • Vote: I do not like it

29.
By adamant, history, 18 months ago, In English
Complex FFT is not as bad as you think ... Probably. Hi everyone! As some of you _might_ already know, I don't like NTT. Primary reasons for this are: - I don't like modular arithmetic optimizations (Montgomery, etc). - I don't like NTT mods, and prefer good, old $10^9+7$. - I do like algebra of complex numbers. But, to my regret, the overwhelming mainstream in modern competitive programming is NTT. Primary reasons are: - It's allegedly faster. - It needs less memory. - It has no precision issues. - People don't like algebra of complex numbers. There is nothing I can do about the last, but today I'll address the first 3. Optimizing complex FFT was on my mind for quite some time, but I didn't really work on it _that much_ until the [blog](https://codeforces.me/blog/entry/142063) by [user:Qwerty1232,2025-04-24] on optimizing NTT has dropped, which motivated me to actually put some serious effort into this. In this blog, we will primarily focus on optimizations that are specific to complex arithmetic...
$$\begin{gather*} \begin{pmatrix}a \\ b \\ c \\ d \end{pmatrix} \mapsto \begin{pmatrix} a + \omega

Full text and comments »

  • Vote: I like it
  • +731
  • Vote: I do not like it

30.
By PinkieRabbit_buster, 3 years ago, In English
PinkieRabbit Cheated in Div. 1 Contest on Apr 27 I am writing to report an incident of cheating by PinkieRabbit during the recent contest 1965 on Codeforces. **PinkieRabbit asked help about problem D from others during the contest,** which is definitely against the contest rules. I have attached the evidence of the cheating behavior in the appendix, please read it. This evidence clearly shows the communications PinkieRabbit had with another person during the contest. It is a contest recording video published after contest by himself. As a former fan of PinkieRabbit, after seeing this video, I was shocked by how dishonest PinkieRabbit was. I believe such actions undermine the integrity of the competition and the platform as a whole. [user:win114514,2024-05-05] cheated by grouping up in contest 1905, finally punished by skipping. Therefore, I respectfully request that Codeforces take appropriate action against PinkieRabbit to maintain the fairness of the contests on Codeforces. He only cheated in one problem this round, so I sugg...
Codeforces. **PinkieRabbit asked help about problem D from others during the contest,** which is, round unrated for PinkieRabbit or skip only problem D (which is very appropriate as far as I am, After it, they talked about their understanding of problem D., F shared ideas about problem D to P., P: So that problem today is really hard to write. Without you, I wouldn't have solvedD., P: without D. Well, without D my performance is probably not very strong., P: 今天那一个题确实难写。哎呀,没有你真的过不了D好吧, P:D去掉。好吧,D去掉可能也没有很强啊 , While PinkieRabbit's conversation is clearly asking for a solution to problem D in the game, the

Full text and comments »

31.
By mnbvmar, 8 years ago, In English
Codeforces Round #556 Hi Codeforces! I'm so happy to invite you to [contest:1149] and [contest:1150]! The rounds will be held on [contest_time:1149]. The round will be rated for both divisions. (At least that's what I've been told!) The problems were written and prepared by me. Thanks to [user:300iq,2019-04-27] for the round coordination, and to [user:Radewoosh,2019-04-27] for his invaluable help with choosing the problemset and testing the problems! Also, I want to give a shout-out to [user:MikeMirzayanov,2019-04-27] for his amazing Codeforces and Polygon platforms! ![ ](http://students.mimuw.edu.pl/~ms360974/stuff/tab-bar2.png) _My browser's tab bar, right now._ You'll work on **5** problems, and you will have **2** hours to solve them. The scoring distribution will be revealed closer to the round. ~~~~~ def get_end_remark(): return random.choice([ "Wish everyone high ratings!", "Good luck!", "Have fun!", "Please, read all the problems!"]) ~~~...
] | 16:27 | [Three Religions](https://codeforces.me/contest/1150/problem/D) | 48:20 | [user:jiangly, ](https://codeforces.me/contest/1150/problem/D) | 48:20 | [user:jiangly,2019-04-29] | | [user:ainta

Full text and comments »

  • Vote: I like it
  • +1064
  • Vote: I do not like it

32.
By tourist, history, 7 years ago, In English
Codeforces Global Round 5 Editorial Enjoy! <spoiler summary="A. Balanced Rating Changes"> [tutorial:1237A] <spoiler summary="Solution by tourist"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int flag = 1; for (int i = 0; i < n; i++) { int x; cin >> x; if (x % 2 == 0) { cout << x / 2 << '\n'; } else { cout << (x + flag) / 2 << '\n'; flag *= -1; } } return 0; } ~~~~~ </spoiler> </spoiler> <spoiler summary="B. Balanced Tunnel"> [tutorial:1237B] <spoiler summary="Solution by tourist"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i]; --a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; --b[i]; } vector<int> pos(n); for (int i = 0; i < n; i++) { pos[b[i...
(int i = 1; i <= k; i++){ int a, b, c, d; cin >> a >> b >> c >> d; if (has1, [tutorial:1237D], ().second.second; v.pop_back(); int ind = 0; ll d = 1e10; for, ; v.pop_back(); int ind = 0; ll d = 1e10; for (int i = 0; i < (int, > p(n, vector(D)); for (int i = 0; i < n; i++) { for (int j = 0; j < D; j, assert((int)answer.size() == ans.fi); printf("%d\n", (int)answer.size()); for (auto &t, const int D = 3;, int main() { scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) scanf("%lld", &a[i, printf("%d ", (int)answer.size()); for (auto t : answer) printf("%d ", t); printf, using ll = long long; using ld = long double; using D = double; using uint = unsigned int

Full text and comments »

  • Vote: I like it
  • +569
  • Vote: I do not like it

33.
By antontrygubO_o, 6 years ago, In English
Some thoughts on recent discussions Hello everyone! I finally decided to write some response/explain my view after all recent discussions of my problems and rounds I coordinate, and I would like to make a few points. **1.** After some recent contests there were a lot of comments saying that Data structure problems should appear as easy problems (say, D2A-D2D in a Div2 of $6$ problems) ![ ](https://i.imgur.com/fmA8zgE.png) ![ ](https://i.imgur.com/m4pJLv6.png) ![ ](https://i.imgur.com/JsryG77.png) I don't think I agree with this. To begin with, I don't think that having Data Structure problem is a requirement for a good contest at all, not just in first few positions. ![ ](https://i.imgur.com/VWAOgxg.png) However, for positions D2A-D2D, I just don't see a way to properly include data structure problems. Take some Data Structure problem, it consists from two parts: <ul> <li> Knowing/implementing the Data Structure </li> <li> Actually thinking about the problem, and how this Data Structure...
:D

Full text and comments »

  • Vote: I like it
  • +1111
  • Vote: I do not like it

34.
By Golovanov399, 7 years ago, In English
C++ tips and tricks Hello, codeforces. I would like to tell you about some tricks and constructions I use in C++. They are not hidden or anything, moreover, most of them are from stl or maybe well known among software engineers, but I often see codes where something is done by hand in, say, 5 lines, while in stl there is a function which does the same. The things below are filtered by my personal sense of non-popularity (so no `__builtin` functions) and usage frequency (so there almost surely are similar things I don't know about) and are not really sorted in any reasonable order. Let's begin. [cut] <hr> - ### `all(x)` This may be an exception to the rule of non-popularity -- this is quite widely used, but some next items will depend on `all(x)`, so I define it here. So, I talk about ```[c++] #define all(x) (x).begin(), (x).end() ``` Now sorting a vector looks like `sort(all(vec))` instead of `sort(vec.begin(), vec.end())`. However, it's not all about this define. Imagine you nee...
```[c++] int x = min(min(min(a, b), c), d); ```, ```[c++] int x = min({a, b, c, d}); ```

Full text and comments »

  • Vote: I like it
  • +756
  • Vote: I do not like it

35.
By maomao90, 3 years ago, In English
Editorial for Hello 2024 ### [problem:1919a] Author: [user:maomao90,2024-01-02] <spoiler summary="Hint 1"> When does the game end? </spoiler> <spoiler summary="Solution"> Depending on whether the player chooses to exchange wallets with their opponent on step $1$, $1$ coins will be removed from either the opponent's wallet or the player's wallet. This means that if either of the players still has remaining coins, the game will not end as at least one of the choices will still be valid. The only way that the game ends is when both players have $0$ coins. Since each operation decreases the total amount of coins by exactly $1$, the only way for Alice to win the game is if $a + b$ is odd. </spoiler> <spoiler summary="Code"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; if ((a + b) % 2 == 0) { cout << "Bob\n"; } else { cout << "Alice\n"; } } ...
and the depth of edge $u$ is $d$. We let the weight of the edge $u$ be $10 ^ 9$ and the weight of, --) { d[mx - 1] = f[mx] + (mx > n) - (mx == x); for (int i = mx - 2; i >= mn - 1; i, However, after attaching edge $u$ to one last 2 edges in $c_{d - 1}$, they are no longer isomorphic, However, there is one exception. When the parent edge of $u$ is one of the last 2 edges of $c_{d, Now that we found a leaf, we can use the following method to insert an edge $u$ of depth $d$. We, Now, we just need to handle the issue where the last 2 edges of $c_{d - 1}$ are not isomorphic, ll fact[MAXN * 2], ifact[MAXN * 2]; int t; int n; int f[MAXN * 2], d[MAXN * 2];

Full text and comments »

Tutorial of Hello 2024
  • Vote: I like it
  • +760
  • Vote: I do not like it

36.
By sevlll777, 4 years ago, translation, In English
Codeforces Round 860 (Div. 2) Hello Codeforces! I am happy to invite you to [contest:1798], which will be held on [contest_time:1798]. This round will be **rated for participants with rating lower than 2100**. Participants with a higher rating are invited to participate in the round unofficially. You will be given **6 problems** and **120 minutes** to solve them. All problems were authored and prepared by me. The traditional thanks-list to everyone who took part in the creation of the round: &#129332; [user:DishonoredRighteous,2023-03-19] for coordinating the round &#128030; [user:gyh20,2023-03-19] for black-red testing of the round &#128520; [user:feecIe6418,2023-03-19], [user:iakovlev.zakhar,2023-03-19], [user:Dart-Xeyter,2023-03-19], [user:Adam_GS,2023-03-19], [user:felys,2023-03-19], [user:golikovnik,2023-03-19], [user:Gary2005,2023-03-19] for red testing of the round &#128043; [user:NemanjaSo2005,2023-03-19], [user:Alexdat2000,2023-03-19], [user:Kon567889,2023-03-19], [user:tem_shett,20...
D: [user:aryan12,2023-03-26]

Full text and comments »

  • Vote: I like it
  • +822
  • Vote: I do not like it

37.
By dario2994, 6 years ago, In English
About Problemsetting (for AtCoder and Codeforces) Since the amount of information available about the preparation of a competitive programming contest for AtCoder/Codeforces is very little, I decided to collect here what was my experience. I will try to both describe my experiences and give some general advice to wannabe problemsetters. I hope that this will be useful to future problemsetters who are "out of the loop". Moreover, participants might be curious to know what happens behind the scenes (and maybe the platforms may consider this as a form of constructive feedback). *Acronyms*: - AGC = Atcoder Grand Contest - GR = Codeforces Global Round ### Why I know something about problemsetting? I am in the competitive programming world since ~8 years: I have participated in IOI/ICPC/GCJ and a number of contests on AtCoder/Codeforces (and lately Codechef). I am not a top participant but, being in this world for so long, I know, more or less, all the standard tricks. Recently, I was the author of the *flagship conte...
AGC44 I was very hard on myself for having given a known problem (problem D) in the contest. Now, I am, a known problem in a contest (see AGC44-D), this is not a huge issue but try to avoid it. - Be, that one of the problems was known (AGC44 D). 3. I had fun interacting with [user:antontrygubO_o,2020, . Preparing the interactive problem (AGC44-D) was an immense pain due to the complete lack of any, I am not a huge fan of some of the problems that appeared in AGC44 or GR11 (for example, AGC-D and

Full text and comments »

  • Vote: I like it
  • +936
  • Vote: I do not like it

38.
By qwexd, 2 months ago, In English
Codeforces Round 1121 (Div. 2) <div class="problem-statement" style="border:0 !important; padding:0 !important; margin:0.5em !important; box-shadow:none !important;"> <div class="header"> <div class="title">1121. Another Round</div> <div class="time-limit"><div class="property-title">time limit per participant</div> 2 hours</div> <div class="memory-limit"><div class="property-title">memory limit per participant</div> 1 brain</div> </div> <div class="legend"> <p> <i>This is <s>an interactive problem</s> a contest with an <b>unusual start time</b>.</i> </p> <p> You are given a Codeforces account and $n = 6$ problems, authored and prepared by [user:qwexd,2026-09-12] and [user:jeroenodb,2026-09-12]. </p> <p> In one operation, you may choose a problem $i$ ($1 \le i \le n$) and submit a program intended to solve it. </p> <p> The maximum scores are given below. Problem E is divided into two subtasks. </p> <div style="overflow-x:auto; margin:0.5em 0 1em;"> <table style="border-collapse:co...
="col" style="border:1px solid #bbb; padding:0.3em 0.6em;">D , > D

Full text and comments »

  • Vote: I like it
  • +1304
  • Vote: I do not like it

39.
By mohammedehab2002, 6 years ago, In English
Codeforces Round #649 (Div.2) Hi everyone! Codeforces round #649 will take place on [contest_time:1364]. It's rated for the second division, but, as usual, first division participants can take part out of competition. The problems were created by me. I'd like to thank my forever orzable coordinator [user:antontrygubO_o,2020-06-11]; my incredible army of testers [user:dorijanlendvaj,2020-06-11], [user:300iq,2020-06-11], [user:Osama_Alkhodairy,2020-06-11], [user:AmShZ,2020-06-11], [user:Taran_1407,2020-06-11], [user:TigranMec,2020-06-11], [user:_Aaryan_,2020-06-11], [user:Mohammad_Yasser,2020-06-11], [user:zoooma13,2020-06-11], [user:lavish315,2020-06-11], [user:Utkarsh.25dec,2020-06-11], [user:NOOBxCODER,2020-06-11], and [user:Laggy,2020-06-11]; and, of course, you-know-who for the amazing codeforces and polygon platforms. This time, in an effort to kill type-races and because I'm lazy, you'll be given 5 problems and 2 hours to solve them. **UPD:** the scoring distribution will be 750-1000-1500-2000-2500...
Good luck & Have fun :D

Full text and comments »

  • Vote: I like it
  • +1165
  • Vote: I do not like it

40.
By TheOneYouWant, history, 6 years ago, In English
Editorial — Codeforces Round #646 Hello, everyone! It was a delight for us to have you participate in our contest. We hope you enjoyed the problems! Here, we present to you the solutions of the problems. I have also prepared some memes for you to enjoy &mdash; disclaimer: not all of them were created by me. [tutorial:1363A] Author of this problem was [user:Ashishgup,2020-05-31]. <spoiler summary="Relevant Meme"> ![ ](/predownloaded/cd/f1/cdf13618b93c6243dec10ec495181286a2616caa.jpg) </spoiler> <spoiler summary="Code for A"> ~~~~~ #include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define int long long const int N = 2e5 + 5; int n, x; int a[N], f[2]; int32_t main() { IOS; int t; cin >> t; while(t--) { f[0] = f[1] = 0; cin >> n >> x; for(int i = 1; i <= n; i++) { cin >> a[i]; f[a[i] % 2]++; } bool flag = 0; for(int i = 1; i <= f[1] && i <= x; i ...
~~~~~ #include using namespace std;

Full text and comments »

  • Vote: I like it
  • +854
  • Vote: I do not like it

41.
By brunomont, 5 months ago, In English
Chinese Postman Problem: How I Ran a 180 km Ultramarathon Through Every Street in My City Hello, Codeforces! A couple of years ago, a friend of mine told me that two cyclists had passed through every single street in the center region of the city I live in (Belo Horizonte, southeastern Brazil), on the [third try](https://www.strava.com/activities/1030665876/overview). <spoiler summary="First try"> After ~160 km, they had not completed 1/3 of the goal. [Strava link](https://www.strava.com/activities/976021527). <img src="/predownloaded/8a/53/8a53829f7d78e88808a3ff751b64406ec2fc0efd.png" style="width: 600.0px;max-width: 100.0%;max-height: 100.0%;"> </spoiler> <spoiler summary="Second try"> They were better prepared, but one of the guys was run over by a car (no big injuries). [Strava link](https://www.strava.com/activities/999450285). <img src="/predownloaded/85/8f/858fdcdcfda93cd1d9c7c59db7dbfad9e63d6ea2.png" style="width: 600.0px;max-width: 100.0%;max-height: 100.0%;"> </spoiler> <center> <img src="/predownloaded/8d/5c/8d5cfb677a361654105e49f36f214c35...
paths $d(i, j)$ between vertices of $O$; 3. Compute the minimum cost perfect matching between vertices, $$ \sum_{v \in V(G)} d(v) \equiv \sum_{v \in V(G)} [d(v) \text{ is odd}] \equiv k \pmod 2 $$

Full text and comments »

  • Vote: I like it
  • +802
  • Vote: I do not like it

42.
By tourist, 5 years ago, translation, In English
VK Cup 2021 — Финал (Engine) и Codeforces Round #740 И снова привет! [contest:1563] начнётся совсем скоро: в [contest_time:1563]. В финале примут участие [32 лучших участника отборочного раунда](https://codeforces.me/contest/1544/standings), которые разыграют между собой солидные призы: - 1-е место — 300 000 рублей; - 2-е — 250 000; - 3-е — 150 000; - 4-е — 100 000; - 5-е — 80 000; - 6-е — 30 000; - и 7-е — 20 000. Следить за ходом соревнования и болеть за любимых участников можно будет [по этой ссылке](https://codeforces.me/spectator/ranklist/2488e608fc1223994a45bca34b4a2c51). Также смотрите прямую трансляцию [в сообществе Команды ВКонтакте](https://vk.com/tech) (нет, спойлеров к задачам финала не будет). Всех остальных, кроме финалистов VK Cup 2021, мы приглашаем на [contest:1558] и [contest:1561], которые начнутся на пару дней позже: во [contest_time:1558]. Раунды будут рейтинговыми для всех. Все задачи были придуманы и подготовлены мной. Большое спасибо всем, без кого этот раунд не смог бы состояться: [user:KAN...
similar to problems F and E of Div. 1 (albeit being much easier). Besides that, problemD of Div. 2, ). Кроме того, для задачи D второго дивизиона добавлена подзадача с меньшими ограничениями, чем в

Full text and comments »

  • Vote: I like it
  • +798
  • Vote: I do not like it

43.
By dario2994, 6 years ago, In English
Editorial of Global Round 11 #### General comments Broadly speaking, problems A-B-C-D were "div2 problems", while F-G-H were "strong grandmaster problems" (with E staying in the middle). I did not expect anyone to solve all the problems and thus I decided to give the scoring F+G=H (so that maybe someone would have solved H). <br><br> Many of the problems (A, C, D, E, G) admit multiple solutions. Sometimes the core of the solution is the same (C, D) and sometimes the solutions are truly different (A, E, G). <br><br> If you are an experienced participant, I would like to hear your opinion on the problems. Feel free to comment on this post or send me a private message. <br><br> <spoiler summary="Overview of the problemset" > The easiest problem of the contest, *A-Avoiding Zero*, is about rearranging an array of numbers. It is intended as a very easy problem that still requires to think. Then, in *B-Chess Cheater* an intuitive (but nontrivial to prove) greedy approach is the way to go. *C-The Hard Work of P...
twist. *D-Unshuffling a deck* is a constructive problem with a multitude of possible solutions (all, #### General comments Broadly speaking, problems A-B-C-D were "div2 problems", while F-G-H were, Many of the problems (A, C, D, E, G) admit multiple solutions. Sometimes the core of the solution

Full text and comments »

  • Vote: I like it
  • +758
  • Vote: I do not like it

44.
By Monogon, 4 years ago, In English
[Tutorial] Supporting Priority-Queue-like Undoing on DS _Good morning!_ In this blog, I will present an online algorithm that can perform priority-queue-like undoing on a data structure, given a few assumptions. I will also present and solve a generalization of that problem. For context, I highly recommend reading this blog that shows how to solve the easier problem of queue-like undoing. That blog gave me the inspiration for the trick I will describe here, but I will still try to write this blog so that it can be understood without it. Thank you [user:Noam527,2023-01-08] for introducing such a great trick to the competitive programming community. [[Tutorial] Supporting Queue-like Undoing on DS](https://codeforces.me/blog/entry/83467) Acknowledgment ----------------- Huge thanks go to [user:peltorator,2023-02-20] for hosting a [blog contest](https://codeforces.me/blog/entry/110840). His generous prize of $300 got many people to write blogs on new, interesting ideas, and it was one of the main reasons I wrote this blog. I'm...
$d$ $\alpha_{opt}$ $\beta$ , ----------------- Let $D$ be a data structure that supports updates and queries. We require $D$ to, all the remaining elements of $U$. In the first case, there needed to be at least $(1-d\alpha)k, are present among the top $d\alpha k$ positions of the stack after operation $i$. Let $U$ be the, generally, what if priorities are $d$-dimensional vectors, and we want to undo the update that has, optimal $\alpha$ value or how the complexity scales up with $d$. To get the best guarantee of complexity, straightforward manner. When we apply an update we push it directly to the stack and apply it to $D, $ remaining elements from $U$ with the highest priorities in dimension $1$ and at most $d\alpha k + m_1-m_2, 1. Apply an update to $D$ with an associated priority $p$. (Assume all priorities are unique). 2, Also with the help of my friend Mr. Wolfram Alpha, we find that $$\lim_{d \to\infty}\frac{1}{d\ f, First, consider the case where $d=1$. In this case, $f(\alpha, 0)=\alpha$ and $f(\alpha, 1)=1, Let $D$ be a data structure that supports updates and queries. We require $D$ to be **commutative, Now let's consider $d\ge 2$. We have that $\alpha<\frac1d\le\frac12\le 1-\frac1d<1-\alpha$ which, The idea is that we have a stack $S$ of updates in the order that we applied them to $D$. If the, This means that $\beta=O(d)$ and so our final complexity becomes $O(dnT(n)\log n)$., This means that if we treat $d$ as a constant, the complexity is $O(nT(n)\log n)$., When we pop elements, we stop when the following condition is met: For each dimension $i=1\ldotsd, {\alpha - d\alpha^2}{\alpha \lambda + (1-\alpha) (1-\lambda)}.$$, }{\min(1-d\alpha, f(\alpha, 0), f(\alpha, 1))},$$

Full text and comments »

  • Vote: I like it
  • +409
  • Vote: I do not like it

45.
By jiry_2, history, 9 years ago, In English
A simple introduction to "Segment tree beats" Hi, I’d like to introduce a simple trick about segment tree in this blog as I promised in [this comment](http://codeforces.me/blog/entry/54750?#comment-387957). Sorry for the long delay, as a sophomore in Peking University, I've just finished a tired semester and a painful final exam. And now I finally have enough time to do a simple introduction to this interesting algorithm. It may be a huge project for me since my English is not good. I think I will finish this blog in several steps and I will try to finish it as soon as possible :) In China, all of the 15 candidates for the Chinese National Team are asked to write a simple research report about algorithms in informatics Olympiad, and the score will be counted in the final selection. There are many interesting ideas and algorithms in these reports. And I find that some of them are quite new for competitors in CF although they are well known in China from the final standings of some recent contests. For example, In the last co...
choose is a little strange: let $d(t)$ ( $t$ is a tag ) be the depth of $t$ in the segment tree and, And these tags can be merged: $f_{a,b}(f_{c,d}(x)) = \max(\max(x + c, d) + a, b) = \max(x + a+c, {a,b}(x),h_{c,d}(x))$ to a node in which the old tag is $(f_{e,f}(x),h_{g,h}(x)$, the historic

Full text and comments »

  • Vote: I like it
  • +771
  • Vote: I do not like it

46.
By MikeMirzayanov, 5 years ago, In English
C++20 Is Released Hello, Codeforces. Please, welcome c++20 support on Codeforces. Yes, it is 64-bit. Thanks to Brecht Sanders: I used his distribution GCC-11.2.0-64 from https://winlibs.com/. If you have installed [PBOX](http://pbox.me/packages), you can add this compiler with the line `pbox install gcc11-64-winlibs`. Probably, a good idea is to add `C:\Programs\gcc11-64-winlibs\bin` into the PATH. More about PBOX you can read [here](https://codeforces.me/blog/entry/18274). I use the compilation command line similar to other GCC installations: `g++ -Wall -Wextra -Wconversion -static -DONLINE_JUDGE -Wl,--stack=268435456 -O2 -std=c++20 <source>`. The only differences are `-std=c++20` and `-Wall -Wextra -Wconversion` (I plan to use somehow such warnings in Polygon to suggest fixes in uploaded files). Now you can use c++20 in your solutions. I'm not sure there are many features useful in competitive programming. Probably, I'm wrong. For example, now you can write `vector v{vector{1, 2}};` inste...
://docs.google.com/spreadsheets/d /1nOu7wJ1bB-z0WlkkS1FdYMrEoA10_G6f7ccINbSq-jU/edit?usp=sharing). Before, You might be interested in looking at such a [table](https://docs.google.com/spreadsheets/d

Full text and comments »

  • Vote: I like it
  • +1524
  • Vote: I do not like it

47.
By lotusblume, 15 months ago, In English
Worst-Case Graphs for Maximum Flow Algorithms Maximum flow algorithms are known to perform significantly better in practice than their worst-case time complexities would suggest. So in this blog, I will present graphs on which the following maximum flow algorithms actually achieve their worst-case running time: | Algorithm | Time Complexity | | ----------------------- | ------------------------------ | | Ford-Fulkerson with DFS | $\mathcal{O}\big(m^2 \cdot U)$ | | Edmonds-Karp | $\mathcal{O}\big(n \cdot m^2\big)$ | | Dinic | $\mathcal{O}\big(n^2 \cdot m\big)$ | | DFS with Scaling | $\mathcal{O}\big(m^2 \cdot \log(U)\big)$ | | Dinic with Scaling | $\mathcal{O}\big(n \cdot m \cdot \log(U)\big)$ | | Most Improving Augmenting Paths | $\mathcal{O}\big(m \cdot \log(U) \cdot (m + n \cdot \log(n))\big)$ | | FIFO Preflow Push | $\mathcal{O}\big(n^3\big)$ | | Highest-Label Preflow Push | $\mathcal{O}\big(n^2 \cdot \sqrt{m}\big)$ | Here and in the rest of this blog: - $n =$ number of vertices, ...
\rightarrow a \rightarrow f \rightarrow g \rightarrow b \rightarrow h \rightarrow c \rightarrowd, [1] Donald Goldfarb and Michael D. Grigoriadis. "A Computational Comparison of the Dinic and

Full text and comments »

  • Vote: I like it
  • +927
  • Vote: I do not like it

48.
By tourist, history, 10 years ago, translation, In English
VK Cup 2017 Round 3 + Codeforces Round #412 -- Tutorial Here is the tutorial of VK Cup 2017 Round 3 and Codeforces Round #412. Enjoy! <spoiler summary="Is it rated?"> [tutorial:807A] <spoiler summary="Code"> ~~~~~ n = int(input()) results = [] for i in range(n): results.append(list(map(int, input().split()))) for r in results: if r[0] != r[1]: print("rated") exit() for i in range(n): for j in range(i): if results[i][0] > results[j][0]: print("unrated") exit() print("maybe") ~~~~~ </spoiler> </spoiler> <spoiler summary="T-Shirt Hunt"> [tutorial:807B] <spoiler summary="More efficient code"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int p, x, y; cin >> p >> x >> y; for (int s = y; ; s++) { if (s % 50 != x % 50) { continue; } bool me = false; int i = s / 50 % 475; for (int j = 0; j < 25; j++) { i = (i * 96 + 42) % 475; if (i + 26 == p) { me = true; ...
("%d\n", (max(0, s - x) + 50) / 100); break; } } return 0; } ~~~~~ , ; break; } } if (me) { printf("%d\n", (max(0, s - x) + 50) / 100, int a[N][N]; long long d[N]; bool used[N];, int main() { // reading input data int n; scanf("%d", &n); for (int i = 0; i < n; i, int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j, int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i, int main() { int t; scanf("%d", &t);, using ll = long long; using ld = long double; using D = double; using uint = unsigned int

Full text and comments »

  • Vote: I like it
  • +570
  • Vote: I do not like it

49.
By Qingyu, 16 months ago, In English
About the Universal Cup, the Semifinals, and myself... Hey'all! This gonna be a long post, so let me put an important TLDR here first: we are going to host **The 3rd Universal Cup Semifinals**, which will take place on August 24, 2025 **online**, at [11:00 (UTC)](https://www.timeanddate.com/worldclock/fixedtime.html?msg=The+3rd+Universal+Cup+Semifinals&iso=20250824T19&p1=33&ah=5). This contest will be a part of our Finals Team Selection, which the detailed rules and announcements will be published later next week. --- Now for some extra context, if you're interested. Last week, we hosted the [last online stage](https://codeforces.me/blog/entry/143954) of The 3rd Universal Cup. After that, I posted a [feedback form](https://docs.google.com/forms/d/1g5Txhiirh_lRsvGfkYWRozu0WDDGK31IAXjB7VgeVoM/edit) on our discord server. I received lots of thoughtful responses (P.S — it's still open, so feel free to fill it out if you haven't yet!). I've read through all the feedback, and I'd like to share a few thoughts. ### On the Number...
Universal Cup. After that, I posted a [feedback form](https://docs.google.com/forms/d

Full text and comments »

  • Vote: I like it
  • +814
  • Vote: I do not like it

50.
By Phantasmagorias, history, 5 years ago, In English
Codeforces Round #745 Editorial I'm very sorry about all the inconvenience, and I would like to bear the blame. Much thanks to those who help me prepare this round. It's not their fault. And much thanks to your participation. [problem:1581A] ------------------ idea: [user:interlude,2021-09-30] preparation: [user:CQXYM,2021-09-30] tutorial: [user:CQXYM,2021-09-30] Assume a permutation $p$, and $\sum_{i=2}^{2n}[p_{i-1}<p_i]=k$. Assume a permutaion $q$, satisfying $\forall 1 \leqslant i \leqslant 2n, q_i=2n-p_i$. We can know that $\forall 2 \leqslant i \leqslant 2n,[p_{i-1}<p_i]+[q_{i-1}<q_i]=1$. Thus,$\sum_{i=2}^{2n}[q_{i-1}<q_i]=2n-1-k$, and either $p$ should be counted or $q$ should be counted. All in all, the half of all the permutaions would be counted in the answer. Thus, the answer is $\frac{1}{2}(2n)!$. The time complexity is $O(\sum n)$. If you precalulate the factors, then the complexity will be $O(t+n)$. ----- <spoiler summary="solution"> ~~~~~ #include<stdio.h> int f[100001]; int m...
$f_{l,s,d}=\sum_{a=1}^{l} \binom{l-1}{a-1} \sum_{x=0}^{s}f_{a-1,x,d +1}f_{l-a,s-x-[d=k],d+1}$, ("%d%d%d",&n,&m,&k); if((n-1ll)*n>>11, ().second; ll d = -pq.top().first; pq.pop(); if (dis[u] != d) continue, ; if(typ)for(int i=1,d=n>>1;d;i<<=1,d>>=1)for(int j=0;j<<1)for(int k=0;kd*k, ; } int n; scanf("%d",&n); for(register int i=n;i!=0;i--){ scanf("%d",&n); printf("%d\n",f[n, Define the dp state $f_{l,s,d}$ as the number of the permutaion length of $l$ with exactly $d$ such, [lx-1][ly-1]; } inline void Solve(){ int n,m,i,j,k,ans=999999,cur; scanf("%d%d ",&n,&m); for(i, int main() { scanf("%d%d", &N, &M); static int sta[MAX_N], tp; for (int i = 1; i, int main(){ scanf("%d%d",&n,&m); len=n<<1; while(len^len&-len)len^=len&-len; work(m

Full text and comments »

  • Vote: I like it
  • +799
  • Vote: I do not like it

51.
By tourist, history, 9 years ago, translation, In English
Hello 2018 -- Tutorial Here is the tutorial of Hello 2018. Enjoy! <spoiler summary="Modular Exponentiation"> Problem writer: [user:tourist,2018-01-08] [tutorial:913A] <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d %d", &n, &m); printf("%d\n", n >= 31 ? m : m % (1 << n)); return 0; } ~~~~~ </spoiler> </spoiler> <spoiler summary="Christmas Spruce"> Problem writer: [user:BudAlNik,2018-01-08] [tutorial:913B] <spoiler summary="C++ solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> p(n), deg(n); for (int i = 1; i < n; i++) { cin >> p[i]; p[i]--; deg[p[i]]++; } vector<int> sons_leaves(n); for (int i = 0; i < n; i++) { if (deg[i] == 0) { sons_leaves[p[i]]++; } } for (int i = 0; i < n; i++) { if (deg[i] > 0 && sons_leaves[i] < 3) { puts("No"); return 0; } } puts...
int main() { int n, L; scanf("%d %d", &n, &L); vector c(n); for (int i = 0; i < n, int main() { int n, T; scanf("%d %d", &n, &T); vector a(n), t(n); for (int i = 0, int main() { int n, T; scanf("%d %d", &n, &T); vector< vector< pair > > at(n + 1, int main() { int n, m; scanf("%d %d", &n, &m); printf("%d\n", n >= 31 ? m : m % (1 << n

Full text and comments »

Tutorial of Hello 2018
  • Vote: I like it
  • +463
  • Vote: I do not like it

52.
By Noam527, 6 years ago, In English
[Tutorial] Supporting Queue-like Undoing on DS In many data structures, the operation of "undo" on the last update can be implemented easily: we can (usually) maintain a stack of the updates, where each update on the stack holds the memory cells it changed, and their original values. To undo an operation, just revert all changes from the top update on the stack. To maintain good complexity, we require the updates to operate in non-amortized time. I've seen this being used multiple times on DSU (without path compression). If we imagine the updates as a sequence, then we can push an update to the end, and pop an update from the end by undo. Then, this sequence is a stack of updates. Here we discuss the idea of having a queue of updates: we can add a new update, or undo the oldest update still active. Specifically, this blogpost attempts to solve the following problem: Given a data structure that can support some updates, some queries and an "undo" operation (each with their own time complexity), how can we create a data structu...
offline D&C algorithm where we have monotonicity (corresponds to queue undoing), and a cool offline, ) online in running time $\mathcal{O}(n \log n \log q)$. There also exist an offlineD&C algorithm

Full text and comments »

  • Vote: I like it
  • +474
  • Vote: I do not like it

53.
By zscoder, history, 6 years ago, In English
[Tutorial] Generating Functions in Competitive Programming (Part 2) Welcome to Part 2 of my tutorial on generating functions. The [first part](https://codeforces.me/blog/entry/77468) focused on introducing generating functions to those without any background in generating functions. In this post, I will demonstrate a few applications of generating functions in CP problems. Let us start with some relatively straightforward examples. Note: Unless stated otherwise, all computations are done modulo a convenient prime (usually $998244353$). Also, $[n]$ denotes the set $\\{1,2,...,n\\}$. ### Blatant Applications in Counting Problems **Problem.** [AGC 005 Problem F](https://atcoder.jp/contests/agc005/tasks/agc005_f) You have a tree $T$ with $n$ vertices. For a subset $S$ of vertices, let $f(S)$ denote the minimum number of vertices in a subtree of $T$ which contains all vertices in $S$. For all $1 \le k \le n$, find the sum of $f(S)$ over all subsets $S$ with $|S| = k$. Constraints: $n \le 2 \cdot 10^{5}$. <spoiler summary="Solution"> First, ...
$ for $0 \le i \le d-1$ into $e^{x}$ and see what happens (note that this is where $e^{-x}$ comes from, $. Thus, if we take $\omega = 7^{\frac{p-1}{d}}$, we will preserve the property that $\omega^{d} = 1, $= \displaystyle\sum_{\sum b_{i} = n, b_{i} \text{ good}}(-1)^{|D |-(m-1)}\frac{n!}{b_{1}!b_{2, $[x^{n}]\frac{1}{d^{k}}\left(\displaystyle\sum_{i=0}^{d-1} u^{a_i}v^{b_i}\right)^{k}$., $\frac{1}{d^{k}}\left(e^{x} + e^{\omega x} + e^{\omega^{2} x} + ... + e^{\omega^{d-1} x}\right)^{k}$., $\frac{1}{n}[x^{n-1}]\left(\frac{C(x)}{1-(x+1)y}\right)'D(x) = \frac{1}{n}[x^{n-1}]\frac{C'(x)D(x, $\left(1 + \frac{x^d}{d!} + \frac{x^{2d}}{2d!} + ... +\right)\left(1 + \frac{x^d }{d!} + \frac{x^{2d, $e^{\omega x} = 1 + \frac{\omega x}{1!} + \frac{\omega^{2} x^2}{2!} + ... + \frac{\omega^{d} x^{d, $e^{\omega^{d-1} x} = 1 + \frac{\omega^{d-1} x}{1!} + \frac{\omega^{2(d-1)} x^2}{2!} + ... + \frac, $e^{x} + e^{\omega x} + e^{\omega^{2} x} + ... + e^{\omega^{d-1} x} = d\left(1 + \frac{x^d}{d, $e^{x} = 1 + \frac{x}{1!} + \frac{x^2}{2!} + ... + \frac{x^{d}}{d!} + ...$, $f(D) = \displaystyle\sum_{T \subseteq D}(-1)^{|D| - |T|}g(T)$, Constraints: $n \le 10^{9}, k \le 2000, d \in \\{4, 6\\}$., For example, for $d=4$, we have $\omega^{2} + 1 = 0$ and for $d=6$, we have $\omega^{2} - \omega, Let $F(x) = 1 + \frac{x^d}{d!} + \frac{x^{2d}}{2d!} + ...$. How do we write $F(x)$ is a simpler way, Let's substitute this back to our equation. For simplicity, let $D = \{k,2k,3k,...,\} \cap [n-1, Now, our problem reduces to finding $\frac{1}{n}[x^{n-1}]\left(\frac{C(x)}{1-(x+1)y}\right)'D(x, The next step requires some knowledge on roots of unity. The good thing about $d =4,6$ is that $\phi, Thus, if we let $\omega^{i} = a_{i} + b_{i}\omega$, our goal is to find $[x^{n}]\frac{1}{d^{k, To summarize, you can find the expansion of $[x^{n}]\frac{1}{d ^{k}}\left(\displaystyle\sum_{i=0}^{d, ^{i})^{d-1} = 0$ for $i$ not divisible by $d$, we obtain, }!}$ over all tuples of positive integers $(x_{1},x_{2},...,x_{k})$ such that $d |x_{i}$ and $\sum x_

Full text and comments »

  • Vote: I like it
  • +518
  • Vote: I do not like it

54.
By tourist, 9 years ago, In English
My strategy at AtCoder & CS Academy There's been much controversy lately about the late submission strategy not penalized by scoring systems of AtCoder and CS Academy. Most of the relevant discussion happened earlier at http://codeforces.me/blog/entry/53431 and http://codeforces.me/blog/entry/53449. I have a lot of thoughts on the topic, so I've decided to share them in a separate blog post. I really like the strategic part of programming competitions. Of course, problem solving is more important. But every contest consists of multiple problems, so there has to be a way of comparing participants which performed better at different problems. There's a huge variety of scoring rules, and I find it truly amusing. The "submit after solving all problems" strategy looks widely attributed to me now, mostly due to [user:Petr,2017-07-24]'s remarks regarding my participation in AtCoder contests. In my opinion, it's wrong for multiple reasons. A closer five-word description of my strategy is "implement after solvin...
.contest.atcoder.jp/standings) -- I spent more than 10 minutes thinking on E and F before deciding to implement A-D

Full text and comments »

  • Vote: I like it
  • +972
  • Vote: I do not like it

55.
By Um_nik, history, 4 years ago, In English
An unexpected D&C with FFT I came up with this idea when solving [an AtCoder problem](https://atcoder.jp/contests/arc140/tasks/arc140_f), but the editorial had a simpler solution. I liked the idea, so I decided to set [a CodeChef problem](https://www.codechef.com/COOK142A/problems/BOXES) using this idea. Since most of you guys don't participate in CodeChef contests, which is a big mistake, I'll write a short blog explaining the idea. Consider this a spoiler warning for these two problems and a CodeChef promotion. ### Combinatorial problem For given $a$ and $n \le 10^5$ calculate $A_k = \sum_{i=0}^{k} \binom{k}{i} \binom{n-k}{k-i} a^{i}$ for each $k$ from $0$ to $n$. (Use the two links above to see why anybody would like to do that) ### Reformulation with polynomials It is easy to see that $A_k$ is $((1+ax)^{k}(1+x)^{n-k})[x^k]$ (coefficient of $x^k$ in polynomial $(1+ax)^{k}(1+x)^{n-k}$). But since the polynomials are different for different $k$ this doesn't seem very helpful... ### Solution ...
An unexpected D&C with FFT, this polynomial is $d(r-l)$, and since in the end we will be looking only at coefficients from, Let's generalize this a bit and say that $P$ and $Q$ are polynomials of degree at most $d$ and we

Full text and comments »

  • Vote: I like it
  • +277
  • Vote: I do not like it

56.
By Radewoosh, 8 years ago, In English
Blogewoosh #3 Hello, codeforces! This time I've decided to choose a task from my own contest which took place last April and was known as the Grand Prix of Poland. If you want to write this contest virtually in the future, then consider not reading this blog. If you've participated in this contest and maybe even solved this task, then anyway I recommend reading it, cause this task has many very different solutions, each of them being very interesting (in my opinion). It's also a reason why this blog is longer than previous ones. I'll write about task C "cutting tree" (not uploaded to the ejudge yet :/). The statement goes as follows: You are given a tree with $n$ vertices ($1 \leq n \leq 2 \cdot 10^5$). The task is to calculate $f(k)$ for each integer $k$ from the range $[1, n]$ where $f(k)$ is defined as the maximum number of connected components of size $k$ which we can "cut off" from the tree. A connected component of size $k$ is a set of $k$ vertices such that it's possible to traverse ...
comments. See you next time! :D, , take it easy and let me know in the comments. :D

Full text and comments »

  • Vote: I like it
  • +767
  • Vote: I do not like it

57.
By TheScrasse, 3 years ago, In English
Pinely Round 3 (Div. 1 + Div. 2) <img src="https://assets.codeforces.com/images/pinely_logo.png" align="right" style="height: 200px;" alt="text"/> Ciao, Codeforces! We're glad to invite you to take part in [contest:1909], which will start on [contest_time:1909]. You will be given **9 problems** and **3 hours** to solve them. One of the problems will be divided into two subtasks. The problems were authored and prepared by me. <spoiler summary="Spoiler"> ![ ](https://i.imgur.com/lipiKQE.png) </spoiler> We would like to thank - [user:errorgorn,2023-12-20] for his fun &#129292; &#x1F921; &#x1F913; &#x1F629; coordination; - [user:Alexdat2000,2023-12-20] for Russian translation; - [user:franv,2023-12-20] for writing $173$ lines of checker of problem H correctly at the first try; - [user:franv,2023-12-20] for pictures in the editorial; - [user:dario2994,2023-12-20], [user:Endagorion,2023-12-20], [user:ffao,2023-12-20], [user:Golovanov399,2023-12-20], [user:nor,2023-12-20] for VIP testing; - [user:Kaey,202...
- A: [user:Barys,2023-12-23] - B: [user:tourist,2023-12-23] - C: [user:Petr,2023-12-23] -D

Full text and comments »

  • Vote: I like it
  • +797
  • Vote: I do not like it

58.
By Geothermal, history, 6 years ago, In English
Remove Virtual Contestants from Contest Leaderboards As most of you are likely aware, cheating in virtual contests (typically by submitting prewritten or copied solutions in order to appear at the top of the leaderboard) is very common. Most recently, [user:wannabecandidatemaster,2020-05-28] submitted solutions to all problems in [this round](https://codeforces.me/contest/1358/standings) in order to take first place in the standings, and [user:bemandrei,2020-05-28] competed virtually in [this round](https://codeforces.me/contest/1360/standings) after competing in the round officially, and ended up in second place on the leaderboard. In response to the rise of VC cheating (as well as some other issues with the VC system I'll describe below), I'd like to make a simple proposal: **Remove all virtual participants from the contest leaderboards.** The one exception is that you should see your own name on leaderboards for contests you VCed (that is, virtual contestants should be visible only to themselves). Similarly, virtual participan...
first reached GM, I achieved a high rank by noticing a few early solves on D, correctly discerning that

Full text and comments »

  • Vote: I like it
  • +1001
  • Vote: I do not like it

59.
By maomao90, history, 3 years ago, In English
CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!) Hello Codeforces, We are very glad to invite you to participate in [contest:1896], which will start on [contest_time:1896]. You will be given **8 problems** and **2.5 hours** to solve them. The round will be rated for everyone. All the problems are written and prepared by [user:lanhf,2023-11-22], [user:Mike4235,2023-11-22], [user:thenymphsofdelphi,2023-11-22], [user:xuanquang1999,2023-11-22] and me. We would like to give our sincere thanks to: - [user:errorgorn,2023-11-22] for his wonderful coordination! - [user:Alexdat2000,2023-11-22] for translating problem statements. - [user:Um_nik,2023-11-22] and [user:conqueror_of_tourist,2023-11-22] for Legendary Grandmaster testing. - [user:jeroenodb,2023-11-22], [user:Kuroni,2023-11-22], [user:dario2994,2023-11-22] and [user:dreamoon_love_AA,2023-11-22] for International Grandmaster testing. - [user:generic_placeholder_name,2023-11-22], [user:MofK,2023-11-22], [user:minhcool,2023-11-22], [user:dvdg6566,2023-11-22] and [user:mag...
- A: [user:dXqwq,2023-11-26] - B: [user:tourist,2023-11-26] - C: [user:tourist,2023-11-26] -D

Full text and comments »

  • Vote: I like it
  • +788
  • Vote: I do not like it

60.
By scott_wu, history, 7 years ago, In English
New contest format?! Stream feat. tourist, Um_nik Hey all! We've created a new 1v1 programming contest format: **Lockout**. Like in most contests, each round has a set of problems and contestants work to solve them as quickly as they can. In Lockout, however, contestants compete head-to-head and only the first contestant to solve each problem gets the points. Contestants can work on problems in any order, so speed and strategy are crucial to avoid getting sniped! The head-to-head action also makes the contest much more exciting for viewers. We ran the first edition of Lockout at TCO Finals last month as a double-elimination bracket [tournament](https://challonge.com/lockout0). All of the finalists who were available competed (and even some of the problem writers) and we got to see a lot of exciting back-and-forth matches! As you can see though, there's still one set left to play. So we'll be streaming **Grand Finals of Lockout 0 featuring [user:tourist,2019-12-28] vs. [user:Um_nik,2019-12-28]** at [9:30 AM PST](https://www.timea...
E, and try to win outright with either C or D afterwards? Read all the problems first and then

Full text and comments »

  • Vote: I like it
  • +1220
  • Vote: I do not like it

61.
By platelet, 3 years ago, In English
CodeTON Round 5 Editorial ### [problem:1842A] <spoiler summary="Tutorial"> Let's view it as when monsters $x$ and $y$ fight, their health changes into $\max(x-y,0)$ and $\max(y-x,0)$ respectively. So any monster with $0$ health is considered dead. Therefore, a player loses when the health of his monsters are all $0$. Notice that $\max(x-y,0)=x-\min(x,y)$ and $\max(y-x,0)=y-\min(x,y)$. Therefore, after each step, the sum of the health of monsters decrease by the same amount for both players. Therefore, we only need to know $\sum a_i$ and $\sum b_i$ to determine who wins. If $\sum a_i > \sum b_i$, Tsondu wins. Else if $\sum a_i < \sum b_i$, Tenzing wins. Else, it is a draw. </spoiler> <spoiler summary="Code"> ~~~~~ #include <iostream> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(nullptr); int T; cin >> T; while (T--) { int n, m, a[50], b[50]; long long sumA = 0, sumB = 0; cin >> n >> m; for (int i = 0; i < n;...
)$. - For $(a+b)\times (c+d)$, we have $E((a+b)\times (c+d)) = E(ac) + E(ad) + E(bc) + E(bd)$., Firstly, it is impossible to delete ranges $(a,c)$ and $(b,d)$ where $a<d$., Secondly, if we delete ranges $(a,d)$ and $(b,c)$ where $a<d$, we must have deleted range $(b,c

Full text and comments »

  • Vote: I like it
  • +573
  • Vote: I do not like it

62.
By Radewoosh, history, 8 years ago, In English
Blogewoosh #4 Hello, codeforces! It's time to continue the series of Polish tasks. I've decided to write about my own task one more time. Its name is "cook" ([you can submit here](https://szkopul.edu.pl/problemset/problem/9NFtPM59qGWa7wdn570ifuP0/site/?key=statement)). The task isn't very hard, but it uses cute (in my opinion) trick. The statement goes as follows: There is a cook in a restaurant. He has $n$ ($1 \leq n \leq 10^6$) orders which he must fill. Every order is a piece of paper, and all orders are speared on a spindle (sharp stick with pierced pieces of paper) in a fixed order which cannot be changed. Normal cook would just take orders one by one from the top of the spindle and fill them in this order, but the cook in this task has supernatural cooking powers and can combine orders to fill them faster. In particular, if at some moment there are $k$ out of $n$ orders still on the spindle, he can choose one of three options: $---$ He can take the topmost piece of paper and fill this...
. See you next time! :D

Full text and comments »

  • Vote: I like it
  • +752
  • Vote: I do not like it

63.
By Kuroni, history, 7 years ago, In English
Codeforces Round #616 Hello Codeforces o(≧∇≦o) I'm glad to introduce you to [contest:1290] and [contest:1291], which will take place on [contest_time:1290]. Each division will contain **6 problems**, and you will have **2.5 hours** to solve them. There might be interactive problems, feel free to learn about them [here](https://codeforces.me/blog/entry/45307). The problems were created by [user:265918,2020-01-30], [user:Ari,2020-01-30], [user:Kuroni,2020-01-30], [user:gamegame,2020-01-30], and [user:hugopm,2020-01-30]. Now, here are some people I would love to mention: - Thank you [user:isaf27,2020-01-30] for being a super helpful, diligent, and humorous coordinator ヽ(〃・ω・)ノ - Thanks to [user:McDic,2020-01-30], [user:nvmdava,2020-01-30], [user:dorijanlendvaj,2020-01-30], [user:antontrygubO_o,2020-01-30], [user:sdssudhu,2020-01-30], and [user:farmersrice,2020-01-30] for helping with the preparation of the tasks. - Thanks to [user:Sofie_Ever,2020-01-30], [user:mcfr,2020-01-30], [user:MathisHamm...
**UPD3**: Thank you everyone for participating :D Here are the final standings:

Full text and comments »

  • Vote: I like it
  • +739
  • Vote: I do not like it

64.
By twosquares, 11 months ago, In English
Good Bye 2025 Editorial We'd like to thank you all for participating in the contest, and hope you enjoyed it. Any feedback would be appreciated! <!-- You lost the game. --> <spoiler summary="Rate the contest"> - Great contest: - Good contest: - Average contest: - Bad contest: </spoiler> --- <spoiler summary="Did Franklin (from problem D) succeed in massacring a village of innocent elves like Frieren and Dilhan (from problem E)?"> The official lore is that he got lost in a forest of oddly colored Christmas trees (from problem F) and decided instead to write this editorial. </spoiler> <!-- ########### --> <!-- #PROBLEM A# --> <!-- ########### --> <h2>[problem:2178A]</h2> <spoiler summary="Did you like the problem?"> - Great problem: - Good problem: - Average problem: - Bad problem: - Did not solve: ...

Full text and comments »

Tutorial of Good Bye 2025
Tags sus
  • Vote: I like it
  • +697
  • Vote: I do not like it

65.
By Zhtluo, history, 3 years ago, In English
The Reason You are Bad at Codeforces — You are Not Russian Enough If you are triggered by this clickbaity blog title, you are probably interested in improving your Codeforces skills. Now, I will share my point of view on the differences between Codeforces and ICPC contests, and how you can, in my humble opinion, maximize your Codeforces rating gain. I mostly consider that all conceivable competitive programming problems need three aspects of skill: 1. Observation &mdash; the ability to understand the problem and come up with non-trivial properties. 2. Technique &mdash; the ability to apply a well-known algorithm or data structure to the problem. 3. Implementation &mdash; the ability to code fast and debug fast. Collaterally, I refer to these three skills as Russian-ness, Chinese-ness and American-ness, respectively, for reasons you will soon see below. ## Observation (Russian-ness) Observation means that you stare at some problem for a sufficient amount of time and you are able to reduce it to some easier problem. One good proble...
](https://codeforces.me/contest/1889/problem/D). Despite being rated 3000, the problem is solvable in 30

Full text and comments »

  • Vote: I like it
  • +772
  • Vote: I do not like it

66.
By Xellos, history, 11 years ago, In English
Codeforces Round #333 — editorial ### Hints: [div2A](#div2A): Try conversions between bases. [div2B](#div2B): Solve a simpler version of the problem where $A_{i+1} \neq A_i$ for all $i$. [div1A](#div1A): What are the shortest paths of the vehicles? what's the shorter of those paths? [div1B](#div1B): Forget about the ceiling function. Draw points $(i,A[i])$ and lines between them &mdash; what's the Lipschitz constant geometrically? [div1C](#div1C): Some dynamic programming. Definitely not for the exp. score of one person &mdash; look at fixed scores instead. [div1D](#div1D): Compute $dif(v)$ in $O(N)$ (without hashing) and then solve the problem in $O(N^2)$. You need some smart merges. [div1E](#div1E): Can you solve the problem without events of type 1 or 2? Also, how about solving it offline &mdash; as queries on subsets. ![ ](https://i.imgur.com/bnWmD60.png) ### <a name="div2A"></a>Div. 2 A: Two Bases ------------------------------------ It's easy to compare two numbers if the same bas...
abs. difference of adjacent elements! If we replace the array $A[1..n]$ by an array $D[1..n-1]$ of, each of them in $O(N)$ time. One approach that works is assigning a max. difference $D[i]$ to each, with some precomputed values) and compute $P_i$; the answer to the query is $\sum_{i=l}^rD[i]\cdot P_i, ### <>Div. 1 D: Acyclic Organic Compounds ------------------------------------, ### <>Div. 2 D / Div. 1 B: Lipshitz Sequence ------------------------------------, Bonus: the maximum difference permitted in an almost constant range is an arbitrary $D$., If we don't have the whole array $D[1..n-1]$, but only some subarray $D[l..r]$, then we can simply, We can invert it to determine the subarrays for which a given $D[i]$ is maximum: if $D[a_i]$ is the

Full text and comments »

  • Vote: I like it
  • +490
  • Vote: I do not like it

67.
By Radewoosh, history, 8 years ago, In English
Blogewoosh #5 (with images from now) Hello, codeforces! Because after Round #507 sad men in suits visited me in my flat, this time I won't write about any task from the future. Instead, this blog will be about my own trick. I said "my own," but probably some of you have already heard about it or even figured it out, but I've developed it by myself, so I consider it as my own. In particular, it's **GEOMETRY TIME!!!**. But please, don't escape already. I also don't like this topic so much, that's why I really like this trick. Let me tell you a story from one onsite Polish contest, which took place a few months ago. I was thinking about one of the problems, and I've figured out that I had to do some binary-search (on doubles) and then check if a set of half-planes has a non-empty intersection. The answer would tell me in which direction should I turn in the binary search. Firstly, I grabbed my head, because I've never written an intersection of half-planes. I had my acm library with [user:Errichto,2018-09-07]'s code...
time! :D

Full text and comments »

  • Vote: I like it
  • +801
  • Vote: I do not like it

68.
By Bazoka13, history, 5 years ago, In English
Codeforces Round #738 (Div. 2) Hi Codeforces! We are glad to invite you to our first Codeforces Round [contest:1559] which will be held on [contest_time:1559]. This round will be **rated for participants with rating less than 2100**. We will be glad to see participants from the first division to join out of competition as well! In this round, as the best friend of Mocha's, you are going to help her to solve the problems she meets. The problems are prepared by [user:2sozx,2021-08-12], [user:JJLeo,2021-08-12], [user:Serval,2021-08-12], [user:CalvinJin,2021-08-12] and me. We hope you will enjoy the round. :P We would like to thank: - [user:1-gon,2021-08-12] for awesome coordination of this round and helping us improve our problems. - [user:Toxel,2021-08-12] for excellent testing and discussion of this round. - [user:cppascalinux,2021-08-12], [user:PurpleCrayon,2021-08-12], [user:ijxjdjd,2021-08-12], [user:m371,2021-08-12], [user:qxforever,2021-08-12], [user:fixed_lxy,2021-08-12], [user:HKvv,2021...
We recommend you to read the statements of all problems. Good luck & Have fun! : D

Full text and comments »

  • Vote: I like it
  • +796
  • Vote: I do not like it

69.
By codetiger927, history, 5 years ago, In English
Introducing CF Stonks — A Virtual Stock Market Based on Your CodeForces Rating! **2/11/2023 Update**: There had been a month-long hiatus due to the CF name change magic (and my own laziness oops), but everything has been fixed now :D! However, I know a lot of people have gone inactive due to the month-long market closure, so I am hoping to **relaunch StonksCF** in the near future with some new mechanisms (dividends, automatic algorithm trading, etc.). Let me know if you have any ideas! In the meantime, feel free to continue exploiting the way-over-inflated economy and embrace your inner capitalism >:D **Final Update**: We now have our own **DISCORD SERVER**. Join us for the latest information and engage with the community at [https://discord.gg/AeH2GTwkF5](https://discord.gg/AeH2GTwkF5) All the announcements will be there instead of on this page Greetings Fellow CodeForces users! I am proud to introduce my latest project, [CF Stonks](https://codetiger.me/project/StonksCF) (aka StonksCF), which is a virtual stock market based on your CodeForces rating. ...
own laziness oops), but everything has been fixed now :D! However, I know a lot of people have gone, updated! :D Happy trading, Good luck and have fun playing :D

Full text and comments »

  • Vote: I like it
  • +711
  • Vote: I do not like it

70.
By YouKn0wWho, 4 years ago, In English
[Tutorial] Common Mistakes in Competitive Programming and How to Avoid Them One thing is for sure. You do make mistakes. I also make miskates and that's what makes us human. But what we can surely do is &mdash; to try to minimize the errors that we make throughout our life. I have compiled some of the mistakes that I made in my early Competitive Programming phase. I also mentioned how to avoid them. Also, in most cases, I will give you a chance to find out what the bug is before I reveal the culprit as I tried to make this blog interactive. The codes that I have used in this blog have been written in C++ as it is the most used language for CP. **So, if you are new to CP, stick with me as you might don't wanna repeat the mistakes that I made when I was a beginner.** #### Mistake 1 Check out the following code: <spoiler summary="Code"> ~~~~~ #include<bits/stdc++.h> using namespace std; int main() { int a = 1000'000'000,b = 1000'000'000; long long product = a * b; cout << product << '\n'; return 0; } ~~~~~ </spoiler> The outp...
++) { cout << i << '\n'; printf("%d\n", i + 10); } return 0; } ~~~~~

Full text and comments »

  • Vote: I like it
  • +634
  • Vote: I do not like it

71.
By AlperenT, 3 years ago, In English
April Fools Day Contest 2024 Hello, <s>April Fools lovers</s> Codeforces! We, [user:AlperenT,2024-03-26], [user:flamestorm,2024-03-26], [user:toxicpie9,2024-03-26], and [user:willy108,2024-03-26], would like to invite everyone on Codeforces to [contest:1952]! The 12th April Fools Day Contest will take place on [contest_time:1952]. This is a joke competition in which solving the problem is often easier than figuring out what the actual task is. In this round, you will be given $n$ cool bugaboos where $-1 \le n \le \textbf{[REDACTED]}$ and **2** hours to solve them. The contest will use extended ICPC rules (no hacks, the standings are decided by the number of solved problems and penalty time earned on them). You can submit solutions in any language allowed by Codeforces, unless the problem says otherwise. Please note that the round is **unrated** and that the penalty for a **wrong submission** is **10** minutes. To get an idea of what the contest will look like, you can check out the contests of the pas...
-04-01] - D: [user:moraprex,2024-04-01] - E: [user:BalintR,2024-04-01] - F: [user:SanguineChameleon

Full text and comments »

  • Vote: I like it
  • +822
  • Vote: I do not like it

72.
By Errichto, 6 years ago, In English
Matrix Exponentiation tutorial + training contest tl;dr &mdash; video tutorial https://www.youtube.com/watch?v=eMXNWcbw75E and codeforces GYM training https://codeforces.me/gym/102644 (register by finding this contest in GYM instead of using the link directly) video editorial: [part 1 (ABCDEF)](https://www.youtube.com/watch?v=kQuCOFzWoa0) and [part 2 (GHI)](https://www.youtube.com/watch?v=RA_SpxP2t54) codes to all 9 problems: https://github.com/Errichto/youtube/tree/master/matrix-exponentiation Prerequisites: binary exponentiation and iterative dp (you don't need to know matrices) The youtube tutorial ([link](https://www.youtube.com/watch?v=eMXNWcbw75E)) focuses on intuition and graph-like visualization . Or, if you prefer, below is a shorter (less detailed) text tutorial instead. You can practice by solving a set of 9 educational problems in GYM https://codeforces.me/gym/102644. ABCD are easy, EF medium, GHI are hard. If you are stuck, see hints below or watch the full solution analysis &mdash; [part 1 (ABCDEF)](https:...
In the first youtube video, there is graph-like visualization, letter. Letters S and D always make him sad, H makes him happy, and every vowel (AEIOU) flips his mood

Full text and comments »

  • Vote: I like it
  • +606
  • Vote: I do not like it

73.
By triple__a, history, 7 years ago, In English
Codeforces Round #630 (Div. 2) Hello Codeforces! I am glad to invite you to my first official round [contest:1332], which will take place on [contest_time:1332] **(please note for the unusual starting time)** and will be rated for **all Division 2 participants**. You will be given **7 tasks** and **150 minutes** to solve them. All tasks in this round were prepared by me. Hope that you will enjoy those tasks! I would like to thank: - [user:pikmike,2020-03-29] for great coordination of this round, and the idea of solution of one task! - [user:Nanako,2020-03-29], [user:nezzar,2020-03-29] for useful discussion and testing this round! - [user:antontrygubO_o,2020-03-29], [user:McDic,2020-03-29], [user:vovuh,2020-03-29], [user:Flowerandyouth,2020-03-29], [user:socho,2020-03-29], [user:Oak_limy,2020-03-29], [user:Amori,2020-03-29], [user:Stresshoover,2020-03-29], [user:I1I1I11I1I1,2020-03-29], [user:defolaut,2020-03-29], [user:hx073269,2020-03-29] and [user:Pavlova,2020-03-29] for testing this round and...
**D**: [user:wangjunrui,2020-04-01]

Full text and comments »

  • Vote: I like it
  • +713
  • Vote: I do not like it

74.
By TLE, history, 3 years ago, In English
Finally, semantic search for competitive programming problems Hello Codeforces, It has been a long while, but in [this project](https://github.com/fjzzq2002/is-my-problem-new) we close the long-standing open problem proposed by [Umnik 2021](https://codeforces.me/blog/entry/95956). You can try it here _(discontinued, see the new link below)_ while supplies last. Currently I only imported problems from Codeforces & BZOJ (the dead Chinese OJ) but adding other OJs should be easy as long as we have the statements crawled (PRs?). Cheers! **Update (8 months later):** We finally got an update! In the new version I collected and uploaded most of vjudge (which means 160k problems!). It also got a shiny new domain [http://yuantiji.ac](http://yuantiji.ac). Enjoy! :D
](http://yuantiji.ac). Enjoy! :D

Full text and comments »

  • Vote: I like it
  • +1200
  • Vote: I do not like it

75.
By PrinceOfPersia, 12 years ago, In English
Codeforces Round #299 Hi. Codeforces round #299 is gonna take place soon([exact time](http://www.timeanddate.com/worldclock/fixedtime.html?day=14&month=4&year=2015&hour=19&min=30&sec=0&p1=166)) and I'm the writer. I'm lucky to be the first Iranian author in Codeforces, in your and our new year (2015 and 1394). Now, I wanna thank: myself([user:PrinceOfPersia,2015-04-05]) for writing the problems([:P](/blog/entry/16996#comment-217994)), [user:MikeMirzayanov,2015-03-26] for great Codeforces and Polygon platform, [user:Zlobober,2015-04-05] and [user:DamonSalvatore,2015-04-05] and [user:sobhan.miryoosefi,2015-04-05] for helping me prepare this round, [user:Haghani,2015-04-05] and [user:SoroushE,2015-04-05] for testing this round, [user:Delinur,2015-03-26] for translating problem statements into Russian and big thanks to my great buddy, [user:Swift,2015-04-05] for problem legends and the pictures. Also, I wanna thank [user:xiaodao,2015-04-05] for teaching me how to use polygon and testlib and so much oth...
This is my first official contest(after all those contests in Gym :D). I hope you enjoy it.

Full text and comments »

  • Vote: I like it
  • +814
  • Vote: I do not like it

76.
By Radewoosh, history, 7 years ago, In English
Blogewoosh #7 Hello, codeforces! Long time no see, right? So maybe it's a good idea to try to return to my blogs slowly. This time the blog will be about a trick, which usually isn't necessary to solve a task, but can be useful to make implementation much more comfortable. Let's look at [this](https://codeforces.me/contest/932/problem/F) problem. It is about some DP on a tree in which we have to use convex hull trick to improve the complexity. The task requires merging two convex hulls with "smaller to bigger" trick. I recommend you to read the statement before reading the rest of the blog (and the [editorial](https://codeforces.me/blog/entry/57796) if you don't know how to solve it). [cut] $ $ So, how to merge two convex hulls? If we keep them in something like the set from C++, then we can just take every element from the smaller one and try to add it to the bigger one. Unfortunately, adding one element in this way requires some ifology and care. It's hard to implement it, especiall...
more applications for this trick, write about it in the comments. See you next time! :D

Full text and comments »

  • Vote: I like it
  • +697
  • Vote: I do not like it

77.
By -is-this-fft-, history, 6 years ago, In English
How to ask for help in PM There was a blog today with a similar title, and although it was (I think, not really sure as I didn't get a good look) some kind of satire/joke blog, I wanted to post some serious advice about things I (don't) like to see when people are PMing me. However I decided that this wouldn't be in the spirit of the blog and decided to make a separate blog. And now that blog is deleted anyway. While it's not a bad thing to write messages to more experienced users, most people who write me do things that make them very difficult to deal with. These are my opinions, but somewhy I feel that many reds will agree. Some things here feel silly to write because they are so obvious. But I'm only writing them because people regularly mess them up. [cut] $~$ ####Use punctuation and spelling. There are some [very simple rules](https://codeforces.me/blog/entry/82186#comment-689836) that make your messages infinitely more readable. I find it especially strange when many of these messagers call...

Full text and comments »

  • Vote: I like it
  • +746
  • Vote: I do not like it

78.
By MOUFLESS, 18 months ago, In English
Codeforces Round 1025 (Div. 2) ## Ready to Duel? If yes, [user:fzark, 2025-05-09], [user:Intellegent, 2025-05-09], and I are glad to invite you to [Codeforces Round 1025 (Div. 2)](https://codeforces.me/contests/2109), which will be held on [contest_time:2109]. This round will be **rated for participants with rating lower than 2100**. We will also be glad to see the participants with a higher rating to participate in our round unofficially! You will be given **6** problems (with at least one interactive problem and one problem that has 3 versions) and **2 hours and 15 minutes** to solve them. Also you can read about interactive problems [here](https://codeforces.me/blog/entry/45307). **Please take a look at the score distribution; it may help you during the contest. Additionally, make sure to read all the problems.** We would like to thank: - [user:satyam343,2025-05-09], our great beloved coordinator. - [user:Kaitokid,2025-05-09], [user:rui_er,2025-05-09], [user:TripleM5da,2025-05-09], [user:N...
- D: [user:sammyuri,2025-05-17] at 00:10.

Full text and comments »

  • Vote: I like it
  • +684
  • Vote: I do not like it

79.
By Errichto, 8 years ago, In English
Sums and Expected Value — part 1 part 2: https://codeforces.me/blog/entry/62792 Watch my lecture-stream tomorrow (Thursday) at [14:00 CEST](https://www.timeanddate.com/worldclock/fixedtime.html?msg=EV+lecture+1&iso=20181025T14&p1=262) &mdash; <s>[https://www.youtube.com/watch?v=qdlPY37MBPo](https://www.youtube.com/watch?v=qdlPY37MBPo)</s> [https://www.youtube.com/watch?v=U_h3IjreRek](https://www.youtube.com/watch?v=U_h3IjreRek). I will go through theory and problems from this blog. The only prerequisite is knowing what is probability. The next (harder) part on Monday. The video will be available later, with timestamps for each problem &mdash; so you don't have to watch everything. ### Definition of EV Let's say we bought a lottery ticket for 2$. We will win 10$ with probability 10%, and 20$ with p-bility 2%. On average, it gives us $0.1 \cdot 10 + 0.02 \cdot 20 = 1.4$, so we are worse off after buying the ticket. The computed average is called the expected value. The expected value (EV, expecta...
6. **Randomizer (CF 313 D)** You're given a convex polygon with $N$ vertices ($N \le 2000$ or $N

Full text and comments »

  • Vote: I like it
  • +614
  • Vote: I do not like it

80.
By antontrygubO_o, history, 7 years ago, In English
On problemsetting 2 [Previous part](https://codeforces.me/blog/entry/70178) Hi there again! Previous part with opinions of some amazing problemsetters turned out to be interesting for you, so I decided to gather some more opinions :D. I really hope that this post will help someone in their problemsetting future! #### When and how did you start problemsetting? [user:300iq,2020-01-11]: April, 2017 [user:maroonrk,2020-01-11]: In 2015 Summer, I hold the first contest with friends at high school club. It was a local Japanese contest. [user:Radewoosh,2020-01-11]: In high school, so probably for 5 years. I was creating problems for other people from my school as my teacher told me that it's a completely different point of view. [user:voidmax,2020-01-11]: It was 3 years ago. I was on plane and I didn't have a clue what to do in my free time. Then I realized that I can try myself in problemsetting. Later I created first and one of my favorite problem ([problem:963B]). I was full of inspiration a...
interesting for you, so I decided to gather some more opinions :D. I really hope that this post will help, I found that we can use slope sorting + D&C to get the answer for each k on the array with some

Full text and comments »

  • Vote: I like it
  • +631
  • Vote: I do not like it

81.
By -is-this-fft-, history, 4 years ago, In English
On "is this greedy or DP", forcing and rubber bands #### Introduction When it comes to "problem-solving techniques", there are roughly 3 levels: 1. Concrete algorithms (Kruskal's algorithm, Li-Chao tree, fast Fourier transform) 2. General patterns (dynamic programming, greedy, square-root decomposition) 3. Meta-strategies ("how do I even go about solving this problem?") There is some grey area, but in general this classification works well. [Many tutorials](https://codeforces.me/catalog) have been written about ideas that fall into 1 or 2. But very little has been written about the third category. On the catalog, I think the only blogs that really qualify are [this](62730) and [this](20548). There is also [this](92248?#comment-809401) valuable comment. As to why there is so little written, I think I can identify two reasons. - Most strong contestants don't really consciously think about these. After solving a problem with FFT, it's hard not to know you used FFT. If you used DP, even if you did it without thinki...
{d}x$$

Full text and comments »

  • Vote: I like it
  • +548
  • Vote: I do not like it

82.
By okwedook, 6 years ago, In English
Codeforces Round #703 (Div. 2) Hi, Codeforces! I finally get to return something to this great community, so I am glad to invite you to take part in [Codeforces Round #703 (Div. 2)](https://codeforces.me/contest/1486), which will take place on [contest_time:1486]. The round will be **rated for the participants with rating lower than 2100**. Participants from the first division are also welcomed to take part out of competition. You will be given **2 hours 15 minutes** to solve **6 problems**. All the problems were created and prepared by me. One of the problems is interactive, please read [the guide of interactive problems](https://codeforces.me/blog/entry/45307) before the contest. I would also like to thank: <ul> <li> [user:antontrygubO_o,2021-02-16] for excellent coordination! </li> <li> [user:1-gon,2021-02-16], [user:3EVEHAR_KOAVA,2021-02-16], [user:Akulyat,2021-02-16], [user:Aleks5d,2021-02-16], [user:BRCode,2021-02-16], [user:Osama_Alkhodairy,2021-02-16], [user:PO3OBAR_Bblnb,2021-02-16], [user:...
> C2 [user: dlalswp25, 2021-02-19] D [user

Full text and comments »

  • Vote: I like it
  • +908
  • Vote: I do not like it

83.
By DanAlex, history, 11 years ago, In English
How to sweep like a Sir ### Cutting to the chase Clearly you don't need a PhD in Computing to sweep in the yard , but one might be useful in order to know linear and radial sweep algorithms. So , what's all about ? It's just what it sounds it is , sweeping linear ( up to down , for example ) or radial ( making a 360 degrees loop ). How this can help? [cut] Well... ### Linear sweep Suppose you a set of objects in an Euclidean plane. We need to extract information about some objects. The method of linear sweeping takes a line and moves it on a fixed direction. Usually the line taken would be vertical and the direction would be left to right or up to down. ![ ](https://upload.wikimedia.org/wikipedia/commons/2/25/Fortunes-algorithm.gif) Quite abstract for the moment , huh ? Let's go to a more specific example. #### Rectangle union area This example is well known. You have a set of rectangles with edges parallel to the OX and OY axes. What is their union area. Well , first of all , let'...
For the example we have point B C D E F G H. After sorting we have G B E F H D C and the angles, In the given example the set is A,B,C,D,E. Now , as an example , point G would be would cover 2

Full text and comments »

  • Vote: I like it
  • +640
  • Vote: I do not like it

84.
By geranazavr555, 7 years ago, translation, In English
Обновления Polygon (июнь-октябрь 2019) Hello, Codeforces! Я и [user:cannor147,2019-11-07], будучи студентами Университета ИТМО, в июне присоединились к разработке Codeforces. С июня по октябрь мы преимущественно занимались развитием платформы Polygon. В этом посте нам бы хотелось представить вам список того, что мы сделали за это время. В этот список не включены мелкие баг-фиксы или какие-то незаметные пользователям улучшения. #### Пин-коды для контестов и задач Иногда в Polygon разрабатываются особо важные контесты и задачи. В таком случае председатель жюри может быть обеспокоен возможностью утечки, например из-за слабого пароля другого члена жюри. Пин-код &mdash; дополнительный фактор подтверждения доступа к задаче или контесту, его может установить или изменить только владелец задачи или контеста. Предполагается, что пин-код будет передан каким-то отдельным надежным каналом связи. Теперь в интерфейсе контеста для владельцев появилась ссылка Create Pin: ![Create Pin в интерфейсе](https://i.ibb.co/bgcg8Cq/p...
You can find the full description of Polygon API [here](https://docs.google.com/document/d, Полное описание Polygon API можно найти по [ссылке](https://docs.google.com/document/d

Full text and comments »

  • Vote: I like it
  • +739
  • Vote: I do not like it

85.
By TheScrasse, history, 2 years ago, In English
Codeforces Round 975 (Div. 1, Div. 2) Ciao, Codeforces! We're glad to invite you to take part in [contest:2018] and [contest:2019], which will start on [contest_time:2018]. You will be given **6 problems** and **2 hours and 30 minutes** to solve them in both divisions. Some problems will be divided into subtasks. **UPD: the time has been changed to [contest_time:2018], which is different from the time announced before. Please note the unusual starting time.** This round is based on [Italian Olympiad in Informatics (OII) 2024](https://codeforces.me/blog/entry/133905). The problems were authored by [user:lorenzoferrari,2024-09-22], [user:wksni,2024-09-22] and me. We would like to thank - [user:KAN,2024-09-22] for his nutella coordination; - [user:Alexdat2000,2024-09-27] for Russian translation; - [user:bortoz,2024-09-22], [user:collodel,2024-09-22], [user:dp_1,2024-09-22], [user:franfill,2024-09-22], [user:franv,2024-09-22], [user:harniver,2024-09-22], [user:jamesbamber,2024-09-22], [user:Kaey,2024-09-22], ...
-27] - D: [user:eimil,2024-09-27] - E: [user:zzzYteng,2024-09-27] - F: [user:Cylrx,2024-09-27, ] - D: [user:ksun48,2024-09-27] - E1: [user:dorijanlendvaj,2024-09-27] - E2: [user:jiangly,2024

Full text and comments »

  • Vote: I like it
  • +580
  • Vote: I do not like it

86.
By KAN, 20 months ago, In English
Codeforces Blitz Cup 2025 Hi Codeforces! As announced earlier, we’re holding an individual competition, the Codeforces Blitz Cup 2025, to celebrate 15 years of Codeforces. The tournament features PvP matches in a novel Blitz format, where every second (literally!) counts. In a 40-minute match, the opponents rush to solve each consecutive problem quicker than the rival. One needs to come up with a correct solution, think over the optimal implementation, and code cleanly: only the first one to get a problem correctly claims the points. <spoiler summary="Complete Blitz rules"> - Each match lasts 40 minutes, with 7 problems of increasing difficulty (worth 2, 3, 4, 6, 8, 10, and 12 points). - Problems are revealed one at a time, in the order of increasing difficulty. - Only the first contestant to solve a problem earns points. - Once a problem is solved, it becomes unavailable, and the next one is revealed after 60 seconds. Contestants need to code the solution from scratch. It is forbidden to use ...
of the final matches [here](https://docs.google.com/spreadsheets/d/e/2PACX, ) section. [Complete results](https://docs.google.com/spreadsheets/d/e/2PACX

Full text and comments »

  • Vote: I like it
  • +644
  • Vote: I do not like it

87.
By ko_osaga, history, 7 years ago, In English
Story about edge coloring of graph You are given a graph $G$, and for each vertex $v$ you have to assign a positive integer **color** such that every adjacent pair of vertices (vertices directly connected by edge) have different color assigned. You have to minimize the maximum color assigned: In other words, you have to minimize the number of distinct assigned colors. But that's [graph coloring](https://en.wikipedia.org/wiki/Graph_coloring) (vertex coloring). It's hard. Ok, one more time: You are given a graph $G$, and for each **edge** $e$ you have to assign a positive integer **color** such that every adjacent pair of edges (edges sharing same endpoints) have different color assigned. You have to minimize the maximum color assigned: In other words, you have to minimize the number of distinct assigned colors. This is the edge coloring of graph, and I will talk about this now. *Note that this can be interpreted as "graph coloring (vertex coloring) of line graphs". In that sense, you can consider in a similar...
matching that covers all nodes with maximum degree $D$. If all nodes have degree $D$, then simple, maximum degree $D - 1$. We transform the graph $G$ in such a way that the left/right bipartition have, node which originally had degree $D$. So the edges left from the matching still covers all nodes with, reduce the time complexity from $O(D \times MN^{0.5})$ to $O(MN^{0.5} \log D)$., * **Proof**. We use induction on $D$., * **Theorem**. Every bipartite graph can be edge-colored with $D$ colors., * If $D = 0$, the proposition is trivial., . Remove dummy edges, and you still have max degree $\frac{D}{2}$ for each color. So you can recurse, Let $D = max_{v \in V(G)}deg(v)$ be the maximum degree of a graph. Since every vertex should be, Let $L, R$ be a bipartition of this new graph. Now we assume every node of $G$ have degree $D, So if we somehow find the way to color the edges with $D$ colors, the case is closed. This is, The idea is, as you can guess from the $\log$ factor, divide-and-conquer. If $D $ is odd, you can

Full text and comments »

  • Vote: I like it
  • +361
  • Vote: I do not like it

88.
By AlperenT, 7 months ago, In English
April Fools Day Contest 2026 Hello, Codefoolers! We, [user:AlperenT,2026-03-29], [user:Ari,2026-03-29], [user:ToxicPie9,2026-03-29], [user:flamestorm,2026-03-29], [user:prvocislo,2026-03-29], [user:temporary1,2026-03-29], and [user:willy108,2026-03-29] would like to invite everyone on Codeforces to [contest:2214]! The 14th April Fools Day Contest will take place on [contest_time:2214]. This is a joke competition in which solving the problem is often easier than figuring out what the actual task is. In this round, you will be given $n$ problems where $n$ is the number of different AI models I used today and **2** hours to solve them. The contest will use extended ICPC rules (no hacks, the standings are decided by the number of solved problems and penalty time earned on them). You can submit solutions in any language allowed by Codeforces, unless the problem says otherwise. There will be at least one non-interactive problem. In case you do not care about those problems, [here](https://codeforces.me/blog/e...
- C: [user:jdurie,2026-04-03] — 4 minutes - D: [user:thespace,2026-04-03] — 3 minutes

Full text and comments »

  • Vote: I like it
  • +809
  • Vote: I do not like it

89.
By PrinceOfPersia, 12 years ago, In English
Algorithm Gym :: Data structures Today I want to introduce you some very very useful data structures. In this lecture, we are trying to improve your data structures skills, stay with us and click on **read more**. [cut] Important data structures : Trees ----- Trees are one of the most useful data structures.A tree is a connected-acyclic graph.There are too many types of trees, like : rooted trees, weighted trees, directed trees, tries, etc. Partial sum ----------- There are two types of problems solvable by partial sum. 1.Problems which you are asked to answer some queries about the sum of a part of elements (without modify queries). Solution of all of this problems are the same. You just need to know how to solve one of them. Example : You are asked some queries on an array $a_1,a_2,...a,_n$. Each query give you numbers $l$ and $r$ and you should print $a_l + a_{l+1} + ... + a_r$ . Solution : You need to build another array $s_1, s_2, ..., s_n$ which $s_i = a_1 + a_2 + ... + a_i$ ...
Parmida's problem](/contest/459/problem/D), [BST](http://hsin.hr/coci/archive/2008_2009, ![ ](http://www.ics.uci.edu/~dock/manuals/cgal_manual/SearchStructures/d -segment.gif), **Problem** : [A lot of games](/contest/456/problem/D), **Problems** : [Strip](/contest/487/problem/B), [GCDSSQ](/contest/475/problem/D ), [LCM Query](/gym

Full text and comments »

  • Vote: I like it
  • +608
  • Vote: I do not like it

90.
By hugopm, 7 years ago, In English
Codeforces Round #600 (Div. 2) Hello, Codeforces! I'm glad to invite you to [contest:1253], which will be held on [contest_time:1253]. It will be **rated for all participants with rating below 2100**. You will be given **six problems** and **two hours** to solve them. As usual, the score distribution will be announced shortly before the round. The problems were invented and prepared by me. Huge thanks to: - [user:faremy,2019-11-14] for taking time to solve and give me precious feedback on most of the problems I have considered putting into my round throughout its whole creation (more than 6 months!) - [user:300iq,2019-11-14] for coordinating the round and giving helpful advices - [user:MikeMirzayanov,2019-11-14] for great systems Polygon and Codeforces - [user:dorijanlendvaj,2019-11-14], [user:McDic,2019-11-14], [user:nvmdava,2019-11-14], [user:_Kuroni_,2019-11-14], [user:fedoseev.timofey,2019-11-14], [user:Nebuchadnezzar,2019-11-14], [user:opukittpceno_hhr,2019-11-14], [user:aneesh2312,2019-11-14]...
. [user:socketnaut,2019-11-16] (4 minutes) - D. [user:Aya,2019-11-16] (8 minutes) - E. [user:tfg,2019

Full text and comments »

  • Vote: I like it
  • +794
  • Vote: I do not like it

91.
By ko_osaga, history, 4 years ago, In English
SMAWK algorithm as an alternative for D&C optimization Yesterday I participated in a local contest involving a problem about Monge arrays. I could've wrote some d&c optimization, but I got bored of typing it so I copypasted [user:maroonrk,2023-01-01]'s SMAWK implementation to solve it. Today, I somehow got curious about the actual algorithm, so here it goes. ## 1. Definition I assume that the reader is aware of the concept of D&C Optimization and Monge arrays. The goal of SMAWK is to compute the row optima (ex. row minima or maxima...) in a $n \times m$ **totally monotone** matrix. By *totally monotone*, it means the following: **Def: Monotone.** The matrix is monotone if the position of row optima is non-decreasing. **Def: Totally Monotone (TM).** The matrix is totally monotone if every $2 \times 2$ submatrix is monotone. Totally monotone matrices are monotone (proof easy but nontrivial), but not vice versa. The latter is a stronger condition. Note that Divide and Conquer Optimization works on a monotone matrix, therefore ...
SMAWK algorithm as an alternative for D&C optimization, online judges, it seemed a little (1.5x?) faster than the D&C optimization for $N = 200000$., wrote some d&c optimization, but I got bored of typing it so I copypasted [user:maroonrk,2023-01-01]'s, ## 1. Definition I assume that the reader is aware of the concept of D&C Optimization and Monge, * My implementation was not that optimized * D&C optimization has super low constant and likely, * SMAWK is simpler than I thought. * SMAWK is faster than D&C if $N$ is near some million, *But it's not faster or simpler than D&C, why should I learn it?* I mean, like ad-hoc problems, you, , therefore if you can use SMAWK, you can always use D&C Optimization, but maybe not vice versa. I think, ://gist.github.com/koosaga/627f0487faabcac2f189107630d8bb1a): It's not simpler thanD&C optimization

Full text and comments »

  • Vote: I like it
  • +152
  • Vote: I do not like it

92.
By kpw29, 6 years ago, In English
Meet IT Codeforces Round Editorial Thank you very much for taking part in the contest! <spoiler summary="Contest timeline"> - -0:05. Starting the chat with the Questions Answering team: [user:tnowak,2020-11-15] and our beloved coordinator [user:antontrygubO_o,2020-11-15]. We hope that there won't be that many questions :) - -0:01. One minute to go! I hope that everything goes smoothly. I'm so afraid of posting the editorial accidentally that I moved this timeline into another blog... - 0:01. First blood in Div2! Congratulations to [user:majorro,2020-11-15]!. - 0:03. First blood in Div1 as well! Congratulations to [user:Errichto,2020-11-15], your knapsack is ready for a journey to win! - 0:04. [user:Sho10,2020-11-15] first to solve Div2B. Well done! - 0:05. We also have the first question. So far so good... - 0:06. [user:Um_nik,2020-11-15] gets the first pretests pass in Div1B. The cheaters are caught! - 0:09. [user:bandiaoz,2020-11-15] packs the first Knapsack in Div2! A difficulty spike is coming... - 0:12....
Let $D$ be the most frequent value in the whole sequence. If $D, We need to reformulate the condition $d(O, AB) > r$ to make, optimal interval $[a, b]$ in which $D$ is not in the set of most frequent values. Let's think of the

Full text and comments »

  • Vote: I like it
  • +515
  • Vote: I do not like it

93.
By Sanae, history, 6 months ago, In English
Apology for faults in Codeforces Round 1098 Hello, I'm Sanae. In ufc+8 zone, I watched the entire contest at midnight. Too many cheaters emerged and we were busy banning them. I noticed WA submissions on [problem:2228B], [problem:2228C2] and TLE submissions on [problem:2228D], which was intended. Soon after the end of the contest, I released the editorial. The bad news was, the complaints flooded the website and my contribution fell from +91 to -92. After reflecting on the issues, I was anixous and blamed myself. Now, I make an apology to point out the problems to avoid them next time. Sorry, everyone! 1. Too many cheaters emerged. [Comment 1](https://codeforces.me/blog/entry/153617?#comment-1365371) 2. The problems stay in the queue for a very long time bothered contestants. 3. B is easy but many contestants misssed the corner case. And C has many corner cases. [Comment 1](https://codeforces.me/blog/entry/153617?#comment-1365212), [Comment 2](https://codeforces.me/blog/entry/153617?#comment-1365256), [Comment 3...
happens to have many corner cases. TL for D is too tight. Score of E is too low. F is ok but misses, of problem setting. During testing, D was accepted by different solutions and even $O(n\log n, time limit of D is too tight.** [Comment 1](https://codeforces.me/blog/entry/153617?#comment-1365219

Full text and comments »

  • Vote: I like it
  • +813
  • Vote: I do not like it

94.
By Errichto, 4 years ago, In English
Huawei IOI Camp 2022 Hi. I'm organizing an online IOI-preparation camp in collaboration with Huawei. Every day will be a 5-hour virtual contest, then my problem analysis, and sometimes a lecture. There will be at least 4 contests and 2 lectures. We will do some old IOI contests (2013?) from the [IOI archive](https://codeforces.me/blog/entry/104593), CEOI (2015-2016?), or maybe JOI/JOISC &mdash; to be decided this weekend. I don't want to do recent years like 2021 because most participants already covered it. The example lecture topics are those from Range Queries or Trees in [Usaco Guide Platinum](https://usaco.guide/plat). The camp is free for IOI 2022 participants. For everybody else, the video recordings will be posted on Youtube after the camp. By participating you get the live experience (Discord, asking questions, competing with others, leaderboards). **Dates**: 25.07-2.08 (updated) **Time** of every analysis/lecture: [14:00 UTC / 16:00 CEST](https://www.timeanddate.com/worldclock...
Big thanks to Huawei UK R&D for sponsoring this camp.

Full text and comments »

  • Vote: I like it
  • +448
  • Vote: I do not like it

95.
By BledDest, 11 months ago, In English
About ER185, problem D Judging by the comments in the ER announcement, people seriously disliked problem D (to say the least). I want to explain why it exists. But first, I have to admit that I made two serious mistakes when setting the problem. My first mistake is actually putting it into a 2-hour solo round; in its current state, it is much more suitable for a longer contest with a team of three people, where you can actually get some help in debugging the code or verifying your solution logic. The second mistake will be explained a bit later, but I want to say that I understand why people think this is a terrible problem. I am sorry if this problem made the contest much worse for you. However, I am also asking that you consider my point of view. You don't have to agree with it, but I don't want anyone to view me as some insane author who's setting a problem just to watch everyone get furious while implementing it. This is definitely an implementation-heavy problem. But I think that implementation...
About ER185, problem D, I wanted problem D to be one of the problems of the second type: not requiring any algorithms or, Judging by the comments in the ER announcement, people seriously disliked problemD (to say the

Full text and comments »

  • Vote: I like it
  • +181
  • Vote: I do not like it

96.
By JeevanJyot, 5 years ago, In English
Codeforces Round #754 (Div. 2) Henlo Codeforces! We are very glad to invite you to the [contest:1605], which will be held on [contest_time:1605]. This round will be rated for participants with a rating less than $2100$. For higher rated participants, we challenge you to solve problem F ;) All the problems were authored and prepared by [user:Ashishgup,2021-11-08], [user:the_hyp0cr1t3,2021-11-08], [user:ExplodingFreeze,2021-11-08] and me. We have tried our best to create an interesting problemset with clear statements. Hope you enjoy the round :D You will be given $6$ problems and $2$ hours to solve them. We would like to thank: - [user:antontrygubo_O,2021-11-08] for his amazing coordination and help in improving our problems. - Our army of testers: [user:Um_nik,2021-11-08], [user:kefaa2,2021-11-08], [user:1-gon,2021-11-08], [user:_runtimeTerror_,2021-11-08], [user:Jeel_Vaishnav,2021-11-08], [user:AmShZ,2021-11-08], [user:errorgorn,2021-11-08], [user:ijxjdjd,2021-11-08], [user:Utkarsh.25dec,2021-11...
problemset with clear statements. Hope you enjoy the round :D

Full text and comments »

  • Vote: I like it
  • +805
  • Vote: I do not like it

97.
By errorgorn, 5 years ago, In English
Linear Basis (Xor Basis Extended) As part of the graduation requirements for my school, I have to complete a simple research project, so I decided to do something related to data structure and algorithms. I believe I have come out with a data structure that maintains the basis of vectors in $(\mathbb{Z}/m\mathbb{Z})^d$, where $m$ **may not be prime**. Since this was related to competitive programming, I think it is a good idea to share it here. Hopefully, this algorithm is actually novel :P I would like to thank: - [user:icypiggy,2021-12-26] for being my research mentor and tolerating my dumb questions - [user:rama_pang,2021-12-26] and [user:adamant,2021-12-28] for their helpful suggestions and comments Please comment under the blog or message me on codeforces if any parts are unclear or wrong. Also, I hope that some LGMs can help solve the open problems in this blog. # Introduction Maintaining the basis of vectors in $(\mathbb{Z}/2 \mathbb{Z})^d$, also known as the xor basis algorithm is a well-studie...
+ \sum\limits_{k=1}^d \Omega(m_k)) \cdot d^2 + \sum\limits_{k=1}^d \log(m_k))$ assuming addition and, $P(d)$ is clearly true as $A_d =\{0,0,\ldots,0,A_{d,d}\}$ and $\frac{m}{A_{d,d }}A_d=\{0,0,\ldots, $V=\sum\limits_{k=z}^d \mu_k A_k = \mu_z A_z + \sum\limits_{k=z+1}^d \mu_k A_k = (\alpha+\frac{m, Define $V,W$ as $1 \times d$ vectors of elements in $\mathbb{Z}/m\mathbb{Z}$ and $A$ as a $d \times, It is easy to see that the total calls to $\texttt{Extended-Euclidean}$ will take $O(d \log (m, More specifically, given an initially empty set $S$ of vectors in $(\mathbb{Z}/m\mathbb{Z})^d$, we, Therefore, there will only be $O(n+\Omega(m) \cdot d)$ calls to $\texttt{Add-Vector}$. It is easy, cin>>q>>d>>m;, rep(x,0,d) arr[x]=vector(d,0);, vector largest(){ vector res(d,0); rep(x,0,d) if (arr[x][x]){ ll mul=(m-1-res[x, void add_vector(vector v){ rep(x,0,d) if (v[x]){ ll s,t; if (arr[x][x]==0){ tie(s,t

Full text and comments »

  • Vote: I like it
  • +381
  • Vote: I do not like it

98.
By Monogon, history, 6 years ago, In English
[Tutorial] Voronoi Diagram and Delaunay Triangulation in O(n log n) with Fortune's Algorithm What's a Voronoi Diagram? ------------------ Given a set $S$ of $n$ points in the 2D plane, the Voronoi diagram is a partition of the plane into regions. The region associated with a point $p\in S$ contains precisely the points $q$ such that $q$ is closer to $p$ than any other point in $S$. In other words, a point $q$ belongs to the region of its nearest neighbor. <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/54/Euclidean_Voronoi_diagram.svg/1024px-Euclidean_Voronoi_diagram.svg.png" width="300px" height="auto"/> The Voronoi diagram can be represented by the planar graph of boundaries between regions. A vertex in this graph is where three or more segments meet (or a point at infinity), and an edge is a segment connecting two of these vertices. The way the regions were defined, we see that a segment contains the points equidistant to two points in $S$, so it is part of their perpendicular bisector. Similarly, a Voronoi vertex is equidistant to three or more v...
(pt a, pt b, pt c, pt d) { return a + (b - a) * ((c - a).cross(d - c) / (b - a).cross(d - c)); }

Full text and comments »

  • Vote: I like it
  • +499
  • Vote: I do not like it

99.
By GreenGrape, 9 years ago, translation, In English
Codeforces Round #461 (Div. 2) _Привет, Codeforces! Давно не виделись :D_ Codeforces Round #461 состоится [в среду в 20:15 по московскому времени](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Codeforces+Round+%23461+%28Div.+2%29&iso=20180207T2015&p1=352&ah=2). Обратите внимание, что раунд чуть позже, чем обычно. Раунд будет **рейтинговым** для участников из второго дивизиона. Первый дивизион тоже приветствуется, но вне конкурса :) Спасибо Коле ([user:KAN, 2018-02-04]) за координацию раунда, Грише ([user:gritukan, 2018-02-04]), Олегу ([user:x3n, 2018-02-04]), АмирРезе ([user:Arpa, 2018-02-04]) и Сене ([user:senek_k, 2018-02-04]) за тестирование и, конечно, Майку ([user:MikeMirzayanov, 2018-01-01]) за Codeforces и Polygon. Отдельная благодарность отправляется Диме ([user:mitterr1999, 2018-02-04]) и Камилю ([user:pseuda, 2018-02-04]) за идею одной из задач. В этом раунде вы будете помогать игривому монстрику Импу. Не пугайтесь, условия будут короткими! ![ ](https://vk.com/images/stickers/2...
**UPD.** The complete editorial is out (D/F)., **UPD.** Выложены разборы D/F.

Full text and comments »

  • Vote: I like it
  • +674
  • Vote: I do not like it

100.
By Errichto, 7 years ago, In English
Bitwise operations 2 — popcount & bitsets Part 1 ([link](https://codeforces.me/blog/entry/73490)) introduces basic bitwise operations. This is part 2 and it's mainly about (in)famous bitsets and example problems. Also, see links to very useful advanced stuff at the bottom. EDIT: here's [video version](https://www.youtube.com/watch?v=jqJ5s077OKo&list=PLl0KD3g-oDOHpWRyyGBUJ9jmul0lUOD80) of this blog (on my Youtube channel). ### Built-in functions In C++, `__builtin_popcount(x)` returns popcount of a number &mdash; the number of ones in the binary representation of $x$. Use `__builtin_popcountll(x)` for long longs. There are also `__builtin_clz` and `__builtin_ctz` (and their long long versions) for counting the number of leading or trailing zeros in a **positive** number. Read more [here](https://www.geeksforgeeks.org/builtin-functions-gcc-compiler/). Now, try to solve these two simple tasks in $O(1)$, then open the spoiler to check the solution: <spoiler summary="Compute the biggest power of 2 that is a divisor o...
We can split $D$ days into convenient parts of size $64$ and store the availability of a single, What if we are given the availability for the whole year or in general for $D$ days? We can handle

Full text and comments »

  • Vote: I like it
  • +326
  • Vote: I do not like it

101.
By Geothermal, history, 3 years ago, In English
Four Proposals Regarding FSTs While I very much enjoy Codeforces rounds overall, FSTs are by far my least favorite part of the Codeforces contest format. There are two reasons I dislike contests with weak pretests. The first is stylistic: I don't care very much about penalizing people who don't rigorously prove their solutions before submitting (which is the main justification for having weak pretests) and I think it's essentially impossible to FST these solutions without more frequently FSTing contestants who make minor mistakes in their code. (The vast majority of my FSTs are due to this sort of minor glitch rather than an error in the underlying idea). The second is that FSTs introduce an element of hidden information to Codeforces rounds. During a contest, you have no way of knowing whether the authors have written strong pretests. If you act as though the pretests are weak, you will be at a disadvantage if pretests are actually strong (because if you knew pretests are strong, you could have e.g. submit...
Case study: [CodeTON Round 5 D](https://codeforces.me/contest/1842/problem/D). In this problem, I

Full text and comments »

  • Vote: I like it
  • +502
  • Vote: I do not like it

102.
By AkiLotus, 7 years ago, In English
Codeforces Round #614 *"Can you hear me?"* *"Vanessa...?"* ![ ](https://i.imgur.com/82l1lt0.png) Hello Codeforces! We are here to invite you to Codeforces Round #614 (Div. 1) and Codeforces Round #614 (Div. 2), which will take place at [contest_time:1292]. The round is rated for both divisions. This is our first round including Div.1 parts, hopefully you'll find the problems interesting. ;) This round is themed based on the Rayark Inc.'s rhythm game, [_"Cytus II"_](https://www.rayark.com/g/cytus2/). You are about to help our characters in various problems, whether inside or outside of the virtual Internet! Also, feel free to listen to the music tracks I've chosen from the game for each problem (and later, editorial!). ;) Each division will be given **6** problems to solve in **2 hours.** The round's problems were prepared by Xuan-Quang ~xuanquang1999,2020-01-12 D. Nguyen, Duy-Bach ~Akikaze,2020-01-12 Le and Tuan-Dung ~low_,2020-01-12 To. Interactive problem(s) might be found in this ...
roasting a whole bunch of them as well. :D - Grigory ~vintage_Vlad_Makeev,2020-01-12 Reznikov

Full text and comments »

  • Vote: I like it
  • +703
  • Vote: I do not like it

103.
By zscoder, history, 7 years ago, In English
Valentine's Day Contest 2020 Hello everyone! Will you be single and bored during Valentine's Day? Never fear, as [user:zscoder,2020-02-06] is here to cure your boredom. I would like to invite you to Valentine's Day Contest 2020, which will take place on [Friday, February 14, 2020 at 12:30 GMT](https://www.timeanddate.com/worldclock/fixedtime.html?iso=20200214T2030&p1=122&ah=3&am=30). The contest is unofficial and unrated, but the quality of most (if not all) of the problems are comparable to problems from a Codeforces round. I am the author of all problems. The contest format will be IOI format, which means that each problem is worth $100$ points, and there are subtasks for each problem. There will be no time penalty. The problems are **not sorted in increasing order of difficulty**. Unlike IOI, you are allowed to use any templates or notes you have. There are **7 problems** to be solved in **3.5 hours**. There is an interactive problem, so feel free to learn about them [here](https://codeforces.me/...
Problem D: [user:TLE,2020-02-14] at 00:44

Full text and comments »

Announcement of Valentines Day Contest 2020
  • Vote: I like it
  • +564
  • Vote: I do not like it

104.
By PrinceOfPersia, history, 11 years ago, In English
Codeforces Round #326 Hello Codeforces. I'm honored to announce you, that Codeforces round #326 is gonna take place [soon](http://timeanddate.com/worldclock/fixedtime.html?day=15&month=10&year=2015&hour=19&min=30&sec=0&p1=166) on Codeforces. Writers are AmirMohammad Dehghan([user:PrinceOfPersia,2015-10-01]) and Ali Haghani([user:Haghani,2015-10-08]). There will be 6 problems in each division(4 problems are common) and you'll have 2 and a half hour to solve them. I hope you enjoy the problems. I wanna thank Maxim Akhmedov([user:Zlobober,2015-10-01]) for his great helps in preparing this round, [user:MikeMirzayanov,2015-10-01] for wonderful platforms of Codeforce and Polygon, [user:Delinur,2015-10-08] for translating problem statements into Russian and MohammadReza Maleki([user:mruxim,2015-10-13]) and Ali Bahjati([user:AliB,2015-10-13]) for their great advices (and [user:AliB,2015-10-13] again for some graphics). This is my third round on Codeforces and not the last one, I hope. This is the las...
Also congratulations to [user:izrak,2015-10-15], the only one who solved problem Div.1D.

Full text and comments »

  • Vote: I like it
  • +721
  • Vote: I do not like it

105.
By errorgorn, 5 years ago, In English
[Tutorial] Knapsack, Subset Sum and the (max,+) Convolution **Edit**: I have realized that this blog has been sent quite a lot on discord servers, so I am adding a content page at the start to help organize this blog better. ## Prerequisites Let us first define the classical knapsack, unbounded knapsack and subset sum problems. #### Subset Sum There are $N$ items. The $i$-th item has weight $w_i$. Find a set $S$ such that $\sum\limits_{i \in S} w_i = C$. #### Knapsack There are $N$ items. The $i$-th item has weight $w_i$ and value $v_i$. Find a set $S$ such that $\sum\limits_{i \in S} w_i \leq C$ and $\sum\limits_{i \in S} v_i$ is maximized. #### Unbounded Knapsack There are $N$ items. The $i$-th item has weight $w_i$ and value $v_i$. Find a **multiset** $S$ such that $\sum\limits_{i \in S} w_i \leq C$ and $\sum\limits_{i \in S} v_i$ is maximized. You should know how to do both versions of knapsack in $O(NC)$ and subset sum in $O(\frac{NC}{32})$ before reading this blog. In this blog post, I will just show some res...
- If $c<d$, then $ad$ then $a \leq b$, From this, we have several extensions. We can convolute $[ans_{T-D}, ans_{T-D +1}, \ldots, ans_{T, Furthermore, the number of distinct weights is $D$. Then, we have a $O(DC)$ solution $^{[9, Since we have a method of "doubling", which allows us to obtain a complexity of $O(D^2 \log C)$ to, Therefore, we can convolute $[ans_{i-\frac{D}{2}}, ans_{i-\frac{D}{2}+1}, \ldots, ans_{i+\frac{D}{2

Full text and comments »

  • Vote: I like it
  • +345
  • Vote: I do not like it

106.
By chenjb, 3 years ago, In English
The 2nd Universal Cup Semifinal & 2024 Summer Summit Announcement <center> <img src="/predownloaded/a6/3b/a63b8b0dc4b18f3e18c316abc22d4677aa075fd8.png" style="height: 262.0px;max-width: 100.0%;max-height: 100.0%;"> </center> **UPD:** **We plan to host the 2024 Universal Cup Summer Summits in Cancún, Mexico. The event has been scheduled from June 19 to June 23. The detailed schedule, materials, and list of the invited teams will be announced in the future. The 2nd Universal Cup Semifinals will be held on June 23, 2024. The contest will start at 17:00 (UTC +8) and end at 22:00 (UTC +8). Please note that there will be no extra time windows on the semifinals contest &mdash; all the teams must start in the only official time window. You may check the event time on your local timezone here: [Link](https://www.timeanddate.com/worldclock/fixedtime.html?msg=The+2nd+Universal+Cup+Semifinals&iso=20240623T17&p1=33&ah=5). The onsite participants will participate in the semifinals on June 22nd (one day before the online participants)** Hello everyone, w...

Full text and comments »

  • Vote: I like it
  • +553
  • Vote: I do not like it

107.
By E869120, 8 years ago, In English
[Tutorial] A way to Practice Competitive Programming : From Rating 1000 to 2400+ Dear Codeforces community.<br /> Finally red :)<br /> <br /> Today, I want to share about some ways to practice competitive and gain your rating. I hope that this is helpful for those who is practicing competitive programming harder but rating is sluggish. There are 54,000+ people who participated in Codeforces contests actively, but sadly only a few people reach a red-ranked coders. For people who can't reach red, I will introduce my way to gain rating in some steps.<br /> <br /> This blog is an extended and more detailed version of [my previous tutorial blog](http://codeforces.me/blog/entry/53341), but 2 years and now are different. So there are many points that are different from blog which has written 2 years ago. Note: Some people who already read my previous tutorial blog may doubt, but do not doubt &mdash; I should say that the "from rating 1000 to 2000" part of this blog is not the copy of my previous blog and it's very different.<br /> <br /> Since the size is very big...
competitive programming — from rating 1000 to 2400+](https://drive.google.com/file/d

Full text and comments »

  • Vote: I like it
  • +607
  • Vote: I do not like it

108.
By vovuh, history, 6 years ago, In English
My thoughts on clarifications and on the round #677. Alright, I'm done. I wanted to write a blog like that for a long time, but now I really don't have enough patience to ignore this issue anymore. I want to say that I get 100-200 clarifications each Div.3 round. It doesn't even matter how well the statements are, it doesn't matter if there are any issues with solutions or checkers, people always find what to ask. Before I start whining here, I really want to recommend anyone to read these two [user:Um_nik,2020-10-20] blogs: [this one](https://codeforces.me/blog/entry/62730) and [this one](https://codeforces.me/blog/entry/62744). Sorry, [user:Um_nik,2020-10-20], I unnecessarily tagged you, I will not do that anymore. Now some breaking news for most participants: _your local IDE compiler_ and _Codeforces compiler_ are **actually** different things! If your code works fine locally but gets WA/TL/RE/ML/etc on Codeforces, it (most probably) means you have a bug somewhere in your code. There are rare cases when the issue is with comp...
could make this round unrated is the wrong statement of E. He didn't even solve C andD. I asked

Full text and comments »

  • Vote: I like it
  • +979
  • Vote: I do not like it

109.
By .o., 12 years ago, In English
Good Bye 2014 Привет, Codeforces! Добро пожаловать на последний раунд Codeforces в 2014 году, **Good Bye 2014**! Этот раунд *очень необычный*; Во-первых, раунд начинается **[30 декабря в 18:00 по Москве](http://www.timeanddate.com/worldclock/fixedtime.html?msg=Good+Bye+2014&iso=20141230T18&p1=166&ah=2&am=30)**. Во-вторых, раунд длится **2.5 часа**. И в третьих, раунд будет **общим для двух дивизионов**, что означает, что Div1- и Div2-участники не будут разделены. Задачи подготовлены мной ([user:tncks0121,2014-12-29]) и Seunghyun Jo ([user:ainta,2014-12-29]). Это наш второй раунд на Codeforces. После нашего первого раунда случился [чёрный день Codeforces](http://codeforces.me/blog/entry/10683), и мы надеемся, что в этот раз ничего подобного не произойдёт :D Спасибо Won-seok Yoo([user:ainu7,2014-12-29]), который тестировал раунд и обусждал с нами набор задач. Также мы хотим поблагодарить некоторых людей, без которых этот раунд не состоялся бы. Максим Ахмедов ([user:Zlobober,2014-12-29]) с...
://codeforces.com/blog/entry/10683), и мы надеемся, что в этот раз ничего подобного не произойдёт :D, ](http://codeforces.me/blog/entry/10683), we hope this round won't cause any errors like before :D

Full text and comments »

Announcement of Good Bye 2014
  • Vote: I like it
  • +758
  • Vote: I do not like it

110.
By chromate00, 22 months ago, In English
Codeforces Round 1000 (Div. 2) — Anti-LLM Evaluation Report As the main problemsetter of [contest:2063], I know that a lot of you were somewhat disappointed to see that it was not a Div.1 contest. Though I am not the one who caused a lack of Div.1 contests, I understand your feeling. So I present to you the great surprise: The **Anti-LLM Evaluation Report** for [contest:2063], the first of its kind on a Div.2! In this blog we discuss about how the round combats against LLMs (especially focusing on OpenAI o1, the greatest of its kind while we prepared and tested the problemset), by looking at the timeline of how the problemset changed. --- So, let us begin with the initial problemset we had when the testing began. (The task names are anonymized, unless they are released to the public before or in the round) In the beginning, we had a problemset that looks like this: - **A' &mdash; B &mdash; C0 &mdash; D' &mdash; E' &mdash; F0** (If you are confused with the meanings, (letter)' means it was not used in the final problemset but exis...
- **A' — B — C0 — D' — E' — F0**, - **A''**: AC - **B**: **-11** - **C**: **-4** - **D**: **-2** - **E**: **-1** - **F (Easy, - **A'**: **Not Solved**. - **B**: **Not Solved**. - **C0**: Solved. - **D'**: **Not Solved, - Some time after that, some testers pointed out that **D'** is very similar to a task from GCJ

Full text and comments »

  • Vote: I like it
  • +587
  • Vote: I do not like it

111.
By hitman623, 7 years ago, In English
Manthan — Codefest'19 Hello Codeforces! I would like to invite you to [Manthan, Codefest'19](https://codeforces.me/contests/1208), which will take place on [Sunday, August 25, 2019 at 8:05 PM IST](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Manthan%2C+Codefest%2719&iso=20190825T1435&ah=2). This is a **combined Div. 1 + Div. 2** round and is **rated** for participants from both divisions. The Department of Computer Science and Engineering, IIT (BHU) is conducting Codefest from 23rd August &mdash; 25th August. Manthan, the algorithmic programming contest under the banner of [Codefest](https://codefest.tech/), is being held as a special Codeforces round. The round follows regular Codeforces rules. ![ ](/predownloaded/c8/01/c8015f2de382f967d9e531067ca03b5b743e5ed4.jpeg) All problems in this round were created and prepared by [user:drastogi21,2019-08-23], [user:_shanky,2019-08-23], [user:enigma27,2019-08-23], [user:navpun31,2019-08-23], [user:KAN,2019-08-23] and me ([user:hitman623,201...
**D.** [user:ILoLy,2019-08-25]

Full text and comments »

  • Vote: I like it
  • +661
  • Vote: I do not like it

112.
By ko_osaga, history, 13 months ago, In English
Squarepoint Challenge (Codeforces Round 1055, Div. 1 + Div. 2) Editorial Thank you for your participation! Problem A, B were authored by [user:djm03178,2025-10-03]. Problem C was authored by [user:As_dfsdf,2025-10-03]. Problem D was authored by [user:qwerasdfzxcl,2025-10-03]. Problem E, F, G, H1, H2 were authored by [user:ko_osaga,2025-10-03]. [problem:2152A] <spoiler summary="Spoiler"> [tutorial:2152A] </spoiler> <spoiler summary="Code"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; set<int> s; for (int i = 0; i < n; i++) { int x; cin >> x; s.insert(x); } cout << s.size() * 2 - 1 << '\n'; } } ~~~~~ </spoiler> [problem:2152B] <spoiler summary="Spoiler"> [tutorial:2152B] </spoiler> <spoiler summary="Code"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; wh...
int main(){ int t; scanf("%d", &t);, void solve(){ int n, q; scanf("%d %d", &n, &q);, while(q--){ int l, r; scanf("%d %d", &l, &r);

Full text and comments »

  • Vote: I like it
  • +275
  • Vote: I do not like it

113.
By awoo, history, 6 years ago, translation, In English
Educational Codeforces Round 89 [рейтинговый для Div. 2] Привет, Codeforces! В [contest_time:1366] состоится [contest:1366]. Продолжается серия образовательных раундов в рамках инициативы [Harbour.Space University](https://harbour.space/)! Подробности о сотрудничестве [Harbour.Space University](https://harbour.space/) и Codeforces можно прочитать <a href="http://codeforces.me/blog/entry/51208">в посте</a>. Этот раунд будет **рейтинговым для участников с рейтингом менее 2100**. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования. Вам будет предложено **6 или 7 задач на 2 часа**. Мы надеемся, что вам они покажутся интересными. Задачи вместе со мной придумывали и готовили Роман [...
_You can [check it out here](https://drive.google.com/file/d /18jfX7l7VETUShTzC7PhvRuzr9DzsemuZ/view)._, _Вы можете [посмотреть её тут](https://drive.google.com/file/d /18jfX7l7VETUShTzC7PhvRuzr9DzsemuZ

Full text and comments »

  • Vote: I like it
  • +510
  • Vote: I do not like it

114.
By pajenegod, history, 3 years ago, In English
Slowdown bug affecting C++ (64 bit) on Codeforces Yesterday, investigating [Strange TLE by cin using GNU C++20 (64)](https://codeforces.me/blog/entry/126573), I found an easy and reproducable way to trigger a slowdown bug that I believe has been plaguing Codeforces for some time now. So I'm making this blog to raise awarness of it. [user:MikeMirzayanov,2024-03-02], please take a look at this! Here is how to trigger the slowness bug: 1. Take any problem with a relatively large input on Codeforces ($2 \cdot 10^5$ ints is enough). 2. Take a random AC C++ submission that uses `std::cin`. 3. Add the line `vector<vector<int>> TLE(40000, vector<int>(7));` somewhere in global space. 4. Submit using either C++20(64 bit) or C++17(64 bit). 4. ??? 5. TLE For example take [user:Tourist,2024-03-02]'s solution to problem [problem:1936-D]. With the vector of death added to the code, it gets [TLE on TC5](https://codeforces.me/contest/1936/submission/249181295) (taking $> 5$ s). While without the deadly vector, the submission takes [15...
-03-02]'s solution to problem [problem:1936-D] goes from taking [2168 ms](https://codeforces.com, For example take [user:Tourist,2024-03-02]'s solution to problem [problem:1936-D ]. With the vector

Full text and comments »

  • Vote: I like it
  • +658
  • Vote: I do not like it

115.
By YouKn0wWho, 5 years ago, In English
Editorial of Codeforces Round #752 Thanks for participating in my contest <a href="https://emoji.gg/emoji/8771_blobheart"><img src="https://emoji.gg/assets/emoji/8771_blobheart.png" width="16px" height="16px" alt="blobheart"></a>. I hope you liked the problems. I would love to hear your feedback in the comments. If you find anything wrong in the editorial which is more likely to happen because I have written a rather long editorial to make you understand the solutions better, then comment below. Also, don't forget to upvote to pay for the editorial. See you in my next contest! [tutorial:1604A] <spoiler summary="Code"> ~~~~~ #include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int ans = 0; for (int i = 1; i <= n; i++) { int k; cin >> k; ans = max(ans, k - i); } cout << ans << '\n'; } return 0; } ~~~~~ </spoiler> [tutorial:1604B] <spoiler summary="Code"> ~~~~~ #include<bits/stdc++.h> ...
~~~~~ #include using namespace std;, mint pw[N]; mint genius(int n, int k) { if (k == 0) return 1; vector c(k, 0), d (k + 1

Full text and comments »

  • Vote: I like it
  • +517
  • Vote: I do not like it

116.
By maomao90, 2 years ago, In English
Meta Hacker Cup... Why must you be so special?? _Disclaimer: This is a rant about Meta Hacker Cup and may not contain any useful information._ Meta Hacker Cup is one of the biggest annual programming competitions, but it has the strangest submission format, unlike any other online judge. Why does it have to be so different? Let’s take a look at how Meta Hacker Cup 2024 Round 1 went for [user:maomao90,2024-10-06] > The time now is 1:00 AM in Singapore. The contest starts, and maomao90 begins solving the problems. > The time now is 1:41 AM. maomao90 has solved problems A, B, and C without much trouble and starts working on problem D. After quickly coming up with a theoretical solution, maomao90 begins coding. > The time now is 2:05 AM. The code is ready and passes the sample tests. maomao90 proceeds to validate the solution. > The time now is 2:06 AM. Validation passes, and the input zip file is downloaded. > The time now is 2:07 AM. maomao90 runs the code on the final test. ![Image showing assertion failed](https...
on problem D., the disaster with problem D., > The time now is 4:01 AM. Looking at the leaderboard, maomao90 sees the number of WAs on problemD.

Full text and comments »

  • Vote: I like it
  • +510
  • Vote: I do not like it

117.
By Gassa, history, 8 years ago, translation, In English
Язык D в спортивном программировании Всем привет! Недавно участнику [user:yosupo,2018-07-28] задали [вопрос](/blog/entry/51923?#comment-446901) о том, в чём преимущества [языка программирования D](https://dlang.org) в соревнованиях перед языком C++. Я регулярно использую D в соревнованиях (и при подготовке задач) с 2014 года, иногда вполне успешно (например, программа на D принесла мне победу в [AZsPCs: Alphabet City](http://azspcs.com/Contest/AlphabetCity/Standings)). Так что хочу поделиться своим опытом. Постараюсь ограничиться только тем, что имеет значение для соревнований. Общее ощущение такое. На D можно писать как на чистом C, когда нужен полный контроль над происходящим. А можно &mdash; как на Питоне, используя довольно мощную библиотеку. При этом D &mdash; компилируемый язык, так что в обоих случаях производительность сравнима с C++. Кроме того, после написания программы её гораздо проще отладить, чем аналогичную программу на C++. В качестве примера давайте посмотрим на два решения одной ...
The D programming language in competitive programming, Язык D в спортивном программировании, TreeMap. (Как и C++, D может всё, вопрос в нескольких лишних строках и удобстве.), [user:yosupo,2018-07-28] how using the D progamming language compares to using C++. I regularly useD where, problems, D is usually present. (By the way, as is the tradition: thanks to [user:MikeMirzayanov, том, в чём преимущества [языка программирования D](https://dlang.org) в соревнованиях перед языком C, , C++ может всё, но некоторые вещи в других языках, включая D, гораздо удобнее., , метапрограммирование — всё это есть в D изначально. В C++ же, в силу возраста и обратной, , язык D обычно есть. (Кстати, соблюдём традицию: спасибо [user:MikeMirzayanov,2018-07-28]! На этот, ~~~~~ import std.stdio; int main () { int n, m, i; double c = 1.0, x; scanf ("%d %d, Если заинтересовались — взгляните на учебные ресурсы на сайте D: [тур по языку](https, Общее ощущение такое. На D можно писать как на чистом C, когда нужен полный контроль над, У D нет какой-то одной мега-идеи, вокруг которой бы строился язык. Вместо этого есть много мелочей

Full text and comments »

  • Vote: I like it
  • +312
  • Vote: I do not like it

118.
By Um_nik, history, 8 years ago, In English
Codeforces Round #485 (div.1+div.2) Hello! I'm glad to invite you all to Round 485 which will take place on [Tuesday, May 29 at 18:35 UTC+3](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Codeforces+Round+%23485&iso=20180529T1835&p1=166&ah=2). There will be 6 problems in each division, 3 of them are shared between divisions. 2 of div.2 problems created by [user:KAN,2018-05-28], 7 others created by me. The contest duration is 2 hours. My problems were originally used in HSE Championship. I would like to thank [user:Merkurev,2018-05-28] and [user:GlebsHP,2018-05-28] with whom I discussed the problems, [user:I_love_Tanya_Romanova,2018-05-28] for testing, [user:KAN,2018-05-28] for round coordination and Codeforces and Polygon team for these beautiful platforms. I would also like to thank HSE for organizing the event. Oh, and [user:kb.,2018-05-28] for writing great legend for one of the problems (he will be surprised). For those who for some reason like to know score distribution in advance: div.2: 5...
this is subject to change :) UPD: Discussed with [user:KAN,2018-05-29], scores for C andD in div

Full text and comments »

  • Vote: I like it
  • +656
  • Vote: I do not like it

119.
By CoderAnshu, 4 years ago, In English
Codeforces Round #793 (Div. 2) Hi Codeforces! I am pleased to invite you to [Codeforces Round #793 (Div. 2)](https://codeforces.me/contest/1682 "Adhocforces Round"), which will take place on [contest_time:1682]. You will be given **6 problems** and **2 hours** to solve them. The round will be rated for participants of Division 2 with a rating lower than 2100. Division 1 participants can participate unofficially in the round. All problems in this round were prepared by me and [user:rivalq,2022-05-19]. We have worked on this round for a long time and hope you find every problem interesting. I would like to thank: - [user:antontrygubO_o,2022-05-19] for marvellous coordination of the round. - [user:errorgorn,2022-05-19], [user:kclee2172,2022-05-19], [user:AmShZ,2022-05-19], [user:nvmdava,2022-05-19], [user:TheScrasse,2022-05-19], [user:aryanc403,2022-05-19], [user:koderkushy,2022-05-19], [user:PurpleCrayon,2022-05-19], [user:nor,2022-05-19], [user:AlperenT,2022-05-19], [user:towrist,2022-05-19], [user:...
**UPD 2:** Editorial for problems A-D is [here](https://codeforces.me/blog/entry/103097).

Full text and comments »

  • Vote: I like it
  • +616
  • Vote: I do not like it

120.
By FieryPhoenix, 6 years ago, In English
Codeforces Global Round 14 Editorial [problem:1515A] Idea: [user:FieryPhoenix,2021-05-02] <spoiler summary="Tutorial"> [tutorial:1515A] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; void solve(){ int n,x; int w[101]; cin>>n>>x; int sum=0; for (int i=0;i<n;i++){ cin>>w[i]; sum+=w[i]; } //if the sum is x, we cannot avoid the explosion if (sum==x){ cout<<"NO"<<endl; return; } cout<<"YES"<<endl; //otherwise, the answer always exists //we will keep adding elements from left to right //if we can't add element i, we add element i+1 first by swapping the two for (int i=0;i<n;i++){ if (x==w[i]){ //i+1 will always be less than n because otherwise, the total sum would be x swap(w[i],w[i+1]); } cout<<w[i]<<' '; x-=w[i]; } cout<<endl; return; } int main(){ int T; cin>>T; while (T--) solve(); return 0; } ~~~~~ </spoiler> [problem:1515B] Ide...
int main(){ int N,M; scanf("%d %d",&N,&M); for(int i=0;i, int main(){ int Q; scanf("%d %d",&N,&Q); for(int i=0;id %d

Full text and comments »

  • Vote: I like it
  • +376
  • Vote: I do not like it

121.
By duality, 3 years ago, In English
Codeforces Round #884 (Div. 1 + Div. 2) Editorial Video editorials for [B](https://www.youtube.com/watch?v=5nzUni8dFLQ), [C](https://www.youtube.com/watch?v=8mz7gnAJ5QM), and [D](https://www.youtube.com/watch?v=ahnNAwpGwHc) are available on [user:ak2006,2023-07-11]'s channel. ### [problem:1844A] <spoiler summary="Hint 1"> There exists a small $n$ where the second player can win. </spoiler> <spoiler summary="Hint 2"> If $a \ge 2$, then $n = 1$ works. </spoiler> <spoiler summary="Solution"> [tutorial:1844A] </spoiler> <spoiler summary="Implementation"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int t,a,b; scanf("%d",&t); while (t--) { scanf("%d %d",&a,&b); printf("%d\n",a+b); } return 0; } ~~~~~ </spoiler> ### [problem:1844B] <spoiler summary="Hint 1"> In order for $(l,r)$ to contribute to the primality, we must have $\operatorname{MEX}(a_l,\dots,a_r) \ge 2$, so there is some value $1$ between indices $l$ and $r$. </spoiler> <spoile...
; int x1,y1,x2,y2; scanf("%d",&t); while (t--) { scanf("%d %d %d",&n,&m,&k, ; scanf("%d",&t); while (t--) { scanf("%d %d",&n,&c); for (i = 0; i < n, int a[200000]; int main() { int i,j; int t,n,c; scanf("%d",&t); while (t, int c[200000]; int main() { int i; int t,n; scanf("%d",&t); while (t, int main() { int t,a,b; scanf("%d",&t); while (t--) { scanf("%d %d",&a,&b

Full text and comments »

  • Vote: I like it
  • +379
  • Vote: I do not like it

122.
By tourist, 4 years ago, In English
Codeforces Round #844 Editorial [problem:1782A] <spoiler summary="Explanation"> [tutorial:1782A] </spoiler> <spoiler summary="Source"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int tt; cin >> tt; while (tt--) { int w, d, h; cin >> w >> d >> h; int a, b; cin >> a >> b; int f, g; cin >> f >> g; int ans = b + abs(a - f) + g; ans = min(ans, a + abs(b - g) + f); ans = min(ans, (d - b) + abs(a - f) + (d - g)); ans = min(ans, (w - a) + abs(b - g) + (w - f)); cout << ans + h << '\n'; } return 0; } ~~~~~ </spoiler> [problem:1782B] <spoiler summary="Explanation"> [tutorial:1782B] </spoiler> <spoiler summary="Source 1"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int tt; cin >> tt; while (tt--) { int n; cin >> n; vector<int> cnt(n + 1); for (int i = 0; i < n; i++) { int a; cin >> a; cnt[a] += 1; } int ans = 0; ...
int main() { int tt; cin >> tt; while (tt--) { int w, d, h; cin >> w >> d >> h

Full text and comments »

  • Vote: I like it
  • +253
  • Vote: I do not like it

123.
By -is-this-fft-, history, 2 years ago, In English
PSA on Meta Hacker Cup (must read if its your first time!) Meta Hacker Cup is upon us again. Along with it comes the unique format where we have to run our code on large test cases ourselves. Unfortunately, past experience shows that not everyone knows how to do this reliably. Usually, after the first round, many people lose points as a result of an unreliable workflow. This time, let's try to prevent that from happening. Sorry for the somewhat self-important title, but I really do wish that everyone understood this and that no one will fail the contest because of this. ### Don't EVER copy-paste huge files A lot of people's workflow to run a solution is the following: - Click some green button in the IDE - A box comes up, copy-paste the input into that box - The output shows up somewhere This may work well for running your solution on small sample test cases. It is **terrible** for running your solution on the huge test cases in Meta Hacker Cup. In last year's Round 1, the full test case for [problem C](https://www.facebook.com...
void dfs (int u, int d) { depth[u] = d; for (int nxt : ch[u]) dfs(nxt, 1 + d); }

Full text and comments »

  • Vote: I like it
  • +310
  • Vote: I do not like it

124.
By Lyde, 4 years ago, In English
Sometimes it's not their fault. Hello! It's 2023 now, and everyone is happy and hoping for a good year, which many good contests to come. So I want to say about one thing that I saw in most of the contests from last year, which I was pretty much annoyed about it and decided to speak about so that this year we will hope to have a better experience doing contests here. I have been in this community for more than 3 years now, not very long, but definitely enough to say that although the number of participants did increase, the number of users increase dramatically, but the number of people that respond to the contests positively don't. It actually did decrease though. I still remember that 500+ upvotes for a contest announcement are a normal thing back then, but I rarely see them now. And a common thing right now, every single contest that is over will have some comments criticizing it, but not in a good way at all. So I will make this quick for certain types of comments like that. I don't know if you do but I ...
Or something like, "D is just boring implementation", "B is harder than C", or "E is just cancer

Full text and comments »

  • Vote: I like it
  • +680
  • Vote: I do not like it

125.
By TheScrasse, history, 3 years ago, In English
Editorial of Pinely Round 3 (Div. 1 + Div. 2) The official implementations of all the problems are [here](https://drive.google.com/file/d/1q2PHS9nJt84FRwfMoiMslQULFE4dTMU4/view?usp=sharing). <spoiler summary="Timeline of the round proposal (may contain spoilers)"> (problems D', H', etc. were not used) - Feb 19, 2022: I proposed problem D' to [contest:1654], but it was not used. - Mar 13, 2023: I invented problem A. - May 16: I invented problem H'. - May 19: I realized problem G can be solved in $O(n)$ time and we used it in the Italian team selection test for IOI. - Jul 04: I opened a Div. 1 proposal containing A, D', G, H' and other problems which are not going to be used. - Aug 09: I invented problem I, with intended solution in $O(n^3)$. - Sep 27: I invented problem C. - Oct 14: [user:errorgorn,2023-12-23] replied to my contest proposal. - Nov 02: I invented problem D''. [user:errorgorn,2023-12-23] solved problem I in $O(n^2 \log n)$. - Nov 08: I invented problems E and F. I didn't propose problem F because I th...
$. Similarly, if $d$ is the minimum integer such that $s_{n-d} \neq t_{m-d}$, $(a+k, b+k)$ is valid for, - visit all the special points with $x = 0$, using the buttons $\texttt{U}$, $\texttt{D}$; - press

Full text and comments »

  • Vote: I like it
  • +354
  • Vote: I do not like it

126.
By Wind_Eagle, history, 5 years ago, translation, In English
Where the author of the contest came up entertaining. Cheating cheaters. Hello, Codeforces! A month ago I have wrote [my blog about cheaters](https://codeforces.me/blog/entry/94300). Under that blog, a number of suggestions have accumulated, and there is a number of interesting ideas that could be applied to sabotage a group of cheaters. I've often seen comments along the lines of: <spoiler summary="Pictures">. <a href="https://imgbb.com/"><img src="https://i.ibb.co/r65zfTL/cheat1.png" alt="pic1" border="0"></a> <a href="https://imgbb.com/"><img src="https://i.ibb.co/Yh6ZfY8/cheat2.png" alt="pic2" border="0"></a> </spoiler> Well, doing what [user:Ari,2021-09-28] suggested wasn't really what I wanted to do, but it was worth checking out what would happen if the wrong solutions were sent. I asked some famous user what would happen if I sent the wrong solutions to cheaters. He told me that someone had done this before and that he was quickly debunked. I wondered whether I could cheat cheaters without getting caught. But for this, I had to do so...
[Problem D](https://ideone.com/yPMiNS), [Задача D](https://ideone.com/yPMiNS)

Full text and comments »

  • Vote: I like it
  • +526
  • Vote: I do not like it

127.
By bashkort, history, 2 years ago, translation, In English
Codeforces Month of Blog Posts Pt. II (Выиграйте $800+!) **TL;DR: Опубликуйте интересный блог на Codeforces до 15 октября и выиграйте $800+1!** **UPD: Мы решили продлить конкурс до 15 ноября!** _Этот блог вдохновлен [месяцем блогов на Codeforces](https://codeforces.me/blog/entry/110840) от [user:peltorator,2024-09-25]._ Привет всем! Прошлый конкурс помог мне тогда, когда я больше всего в этом нуждался. Так что теперь я хочу отплатить сообществу обратно &mdash; организовать Codeforces Month Of Blog Posts еще раз! ### Вступление Мое мнение о блогах совпадает с мнением peltorator'а &mdash; я большой фанат Codeforces, он почти что заменяет мне социальные сети, а блоги &mdash; одна из лучших его частей! Многие люди ждут лучшего времени для публикации своих блогов, откладывают его на потом &mdash; теперь это время пришло! ### Правила и сроки Правила просты: **1. Опубликуйте что-нибудь на Codeforces **(с переводом на английский язык)** не ранее 10 сентября (00:02 UTC) 2024 года.** Мы ищем новые идеи / новые взгляды на темы,...
:D, остаться анонимным D:**

Full text and comments »

  • Vote: I like it
  • +479
  • Vote: I do not like it

128.
By Pyqe, 3 years ago, In English
Codeforces Round #902 (Div. 1, Div. 2, based on COMPFEST 15 — Final Round) <img alt="logo" src="/predownloaded/e3/33/e333915aebea955b43b4ad17845f6dbf58875a0c.png" style="float: right;height: 100.0px;margin: 10.0px;max-width: 100.0%;max-height: 100.0%;"> Sugeng enjing, **Codeforces**! &#x1f970;&#x1f970;&#x1f970;&#x1f970; COMPFEST 15 is happy to invite you to participate in [contest:1876] and [contest:1877] on [contest_time:1876]. Both rounds will be **rated**. You will be given **2 hours and 30 minutes** to solve **7 problems**. **Note the unusual time of the round**. ------------------ The problems are written by [user:ArvinCiu,2023-10-03], [user:Pyqe,2023-10-03], and [user:nandonathaniel,2023-10-03]. We would like to thank: - [user:KAN,2023-10-03] for helping to host the round; - [user:errorgorn,2023-10-03] and [user:ScarletS,2023-10-03] for the based coordination; - [user:gansixeneh,2023-10-03] and [user:nandonathaniel,2023-10-03] for helping with the problem preparation; - [user:ArvinCiu,2023-10-03], [user:CyberSleeper,2023-10-03], an...
] - C: [user:TLEtoAC2001,2023-10-08] - D: [user:34z12000,2023-10-08] - E: [user:Rotting,2023-10-08, ] - C: [user:hehezhoutxdy,2023-10-08] - D: [user:N_z__,2023-10-08] - E: [user:maroonrk,2023-10-08

Full text and comments »

  • Vote: I like it
  • +570
  • Vote: I do not like it

129.
By -is-this-fft-, history, 4 years ago, In English
[Tutorial] FFT If I was a YouTuber, this would be the place where I fill the entire screen with screenshots of people asking me to make this. Anyway, not so long ago I gave a lecture on FFT and now [user:peltorator,2023-01-11] is giving away [free money](https://codeforces.me/blog/entry/110840), so let's bring this meme to completion. In this blog, I am going to cover the basic theory and (competitive programming related) applications of FFT. There is a long list of generalizations and weird applications and implementation details that make it faster. Maybe at some point I'll write about them. For now, let's stick to the basics. **The problem.** Given two arrays $a$ and $b$, both of length $n$. You want to quickly and efficiently calculate another array $c$ (of length $2n - 1$), defined by the following formula. $$c_k = \displaystyle \sum_{i + j = k} a_i \cdot b_j.$$ Solve it in $O(n \log n)$. First of all, why should you care? Because this kind of expression comes up in combinatorics a...
- $(a + bi) + (c + di) = (a + c) + (b + d)i$. - $(a + bi) (c + di) = ac + adi + bic + bdi^2 = (ac

Full text and comments »

  • Vote: I like it
  • +436
  • Vote: I do not like it

130.
By Radewoosh, history, 5 years ago, In English
My own algorithm — offline incremental strongly connected components in O(m*log(m)) Hello Codeforces! As all of you know, there are so many known algorithms named after people who invented them &mdash; from the easiest ones, like Dijkstra, to the harder ones, like Berlekamp–Massey algorithm. These algorithms were innovative when they were invented, so of course, it's good that they are named after their inventors. But, today, I've seen a blog about the solution to the problem "compute LCS of two strings in time $O((n + k) \cdot \log(k))$, where $n$ is the sum of lengths of the strings, and $k$ is the number of pairs of matching positions in them". To be honest, it a bit pissed me off that even this algorithm is named after its creators. Is it ok to name the solution to every possible problem after its author? I won't judge it. Anyway, I want my very own Radecki algorithm, so let me give it a try. If anyone has ever heard about it &mdash; it's cool. Let me know, and it'll be just another helpful blog on Codeforces. Let's imagine the following problem: there is...
solution is the same as mine, here comes a twist: [link](https://drive.google.com/file/d

Full text and comments »

  • Vote: I like it
  • +543
  • Vote: I do not like it

131.
By Xellos, history, 11 years ago, In English
Codeforces Round #333 <center><img src="https://lh3.googleusercontent.com/--HN6DjhjZaM/VlNt6NQ6olI/AAAAAAAAAuQ/w6wSlj7rl0k/s250-Ic42/"></img><div>(<a href="http://i2.kym-cdn.com/photos/images/newsfeed/000/582/289/38f.gif">original</a>)</div></center> Hello everyone! CF round #333 (both divisions) is going to take place [today](https://www.timeanddate.com/worldclock/fixedtime.html?day=24&month=11&year=2015&hour=19&min=35&sec=0&p1=166). The authors of this round are me and [user:Baklazan,2015-11-18]. By total coincidence, I'm the author of even-indexed problems and Baklazan the author of odd-indexed problems. Now I'm going to let you wonder if it's 0-based or 1-based :D. As usual, thanks to [user:GlebsHP,2015-11-19] for his help (in particular, helping us not overkill the problems), [user:MikeMirzayanov,2015-11-19] for CF and Polygon, [user:Delinur,2015-11-24] for problem statement translations and our testers: [user:misof,2015-11-24], [user:Mimino,2015-11-24], [user:AlexFetisov,2015-11-24] and [u...
(homogeneous colours :D)

Full text and comments »

  • Vote: I like it
  • +770
  • Vote: I do not like it

132.
By Elegia, history, 22 months ago, In English
More on D-Finite Functions I: Theories Hello everyone. Several years ago [user:jqdai0815,2025-01-03] released a [blog](https://codeforces.me/blog/entry/76447) on the topic of D-Finite functions. In this blog, I will introduce some more theories, and show the relation between some CP problems. Also, I found out that what I show is like opening Pandora's box: it provides some new ways to solve problems, but they also somehow prevent us from really understanding them. Therefore, I'll also talk about some of my personal critiques on this topic. Since this blog is quite long, I'll divide it into several parts. This is the first part. ## Appetizer We start with this toy problem. **$n$-King Problem.** Given $n$, count the number of permutations $\sigma$ of $[n]$ such that for any $i$, $|\sigma(i) - \sigma(i+1)| \neq 1$. Of course, this sequence has already been studied before, it is the [A002464](https://oeis.org/A002464) in OEIS. You can find its recurrence relation $$ a_n = (n+1)a_{n-1} - (n-2)a_{n-2} - (n-5...
More on D-Finite Functions I: Theories, 1. For any $a,b \in K(X_1,\dots,X_d)$, if $af+bg$ is still a formal power series, it isD-Finite

Full text and comments »

  • Vote: I like it
  • +123
  • Vote: I do not like it

133.
By galen_colin, 6 years ago, In English
Hybrid Tutorial #-1: Heavy-Light Decomposition **[Here](https://www.youtube.com/watch?v=_G_LMuLWMaI&list=PLDjGkpToBsYDx4GWu2u87sTqt6ICELz-T) is a playlist of all hybrid tutorials I've done.** # "Intro" _Timestamp: [00:00](https://youtu.be/_G_LMuLWMaI)_ Hi! Definitely not inspired by [this comment](https://codeforces.me/blog/entry/81086?#comment-675431), I've decided to try something that seems relatively novel &mdash; combining a blog and video tutorial into one, in a "hybrid" fashion. Both should be usable independently, but they will have the same "flow" and structure so you can reference both for concepts that are harder to grasp, and the two will supplement each other. The goal of these is to be **complete** &mdash; beneficial for both video and blog lovers, as well as full of enough information that anyone without much of an idea of what the concept is should be able to fully understand. There will be code as well, however, I very highly recommend not looking at it, but rather working out the implementation for yours...
~~~~~ void dfs_size(int v, int p, int d) { sz[v] = 1; depth[v] = d; par[v] = p; int

Full text and comments »

  • Vote: I like it
  • +404
  • Vote: I do not like it

134.
By cip999, 5 years ago, In English
Editorial of Global Round 15 We hope you liked the problems! Before we go ahead with the editorial, let us make some general comments about this round. Problems A, B, C, D, E, F are "div 2" problems, while problems G, H, I are meant to be solved by Grandmasters. Overall, our goal was to provide a problemset that could be enjoyable for a wide range of participants and such that the winner could solve all the problems. There were three big "jumps" in the difficlty gaps between consecutive problems. Problems A and B are meant to be easy, many contestants have the skills and the techniques to attack them (and, maybe, to solve them). Problems C, D, E, F are gradually harder but the difficulty gap between C and F is not as large as usual (and this is reflected in the score distribution). The same holds for problem G, H, I; the difficulty gap between G and I is relatively small (but there is a big score difference because coding I is much harder). Sadly, we discovered 14 minutes into the round that problem I...
For which values of $d$ is $f(d)$ nicely related to $f(1)$?

Full text and comments »

  • Vote: I like it
  • +533
  • Vote: I do not like it

135.
By AlperenT, 20 months ago, In English
April Fools Day Contest 2025 Hello, Codefoolers! We, [user:AlperenT,2025-03-28], [user:flamestorm,2025-03-28], [user:prvocislo,2025-03-29], [user:temporary1,2025-03-28], [user:Toxicpie9,2025-03-28], and [user:-1e11,2025-03-28], would like to invite everyone on Codeforces to [contest:2095]! The 13th April Fools Day Contest will take place on [contest_time:2095]. This is a joke competition in which solving the problem is often easier than figuring out what the actual task is. In this round, you will be given $n$ problems where $\sum\limits_{x=1}^{\infty} \frac{1}{x^n}$ converges and **2** hours to solve them. The contest will use extended ICPC rules (no hacks, the standings are decided by the number of solved problems and penalty time earned on them). You can submit solutions in any language allowed by Codeforces, unless the problem says otherwise. Please note that the round is **unrated** and that the penalty for a **wrong submission** is **10** minutes. To get an idea of what the contest will look lik...
] (after [user:AprilFoolsClairvoyant,2025-04-03]) - D: [user:koishi.komeiji,2025-04-03] - E

Full text and comments »

  • Vote: I like it
  • +692
  • Vote: I do not like it

136.
By Kaey, 6 years ago, In English
Codeforces Round #701 (Div. 2) Ciao, Codeforces! We're glad to invite you to take part in [contest:1485], which will be held on [contest_time:1485]. This round will be **rated for participants with rating lower than 2100**. You will be given **6 problems** and **2 hours** to solve them. We would like to thank - [user:MrBrionix,2021-02-08], [user:Myk_00L,2021-02-08], [user:taulant,2021-02-01] and [user:TheScrasse,2021-02-08] (a.k.a. the jungkook official fanclub) for inventing and preparing the problems. - [user:isaf27,2021-02-08] for the great coordination and the valuable help he provided at any time. - [user:antontrygubO_o,2021-02-08] for not being involved and hence not rejecting any problem. - [user:MikeMirzayanov,2021-02-08] for creating Codeforces and Polygon. Last but not least, we also want to thank the testers: [user:armyalpaca,2021-02-08], [user:dario2994,2021-02-10], [user:davi_bart,2021-02-08], [user:DeadlyCritic,2021-02-08], [user:franfill,2021-02-08], [user:HIS_GRACE,2021-02-08], [u...
A: [user:m_99,2021-02-11] B: [user:kmjp,2021-02-11] C: [user:Brookli,2021-02-11] D

Full text and comments »

  • Vote: I like it
  • +674
  • Vote: I do not like it