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 ...
$a\bigoplus b + a\bigoplus c > b \bigoplus c \iff cnt_{011}+cnt_{100}>0$, $a\bigoplus c = cnt_{001}+cnt_{011}+cnt_{100}+cnt_{110}$, $b\bigoplus c = cnt_{001}+cnt_{010}+cnt_{101}+cnt_{110}$, $c=cnt_{001}+cnt_{011}+cnt_{101}+cnt_{111}$, =(10)_2,b=(11)_2,c=(01)_2$ then $cnt_{110}=(10)_2,cnt_{011}=(01)_2$, other $cnt$ is 0. $a=cnt_, e.g. $a=(10)_2,b=(11)_2,c=(01)_2$ then $cnt_{110}=(10)_2,cnt_{011}=(01)_2$, other $cnt$ is 0.

Full text and comments »

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

2.
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...
- A: [user:Spawnpoint,2024-01-07] - B: [user:tourist,2024-01-07] - C: [user:tourist,2024-01-07, : [user:tourist,2024-01-07] - C: [user:tourist,2024-01-07] - D: [user:tourist,2024-01-07] - E

Full text and comments »

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

3.
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:LiM_256,2021-07-29], at $0$ mins! B: [user:RinShima,2021-07-29], at $4$ mins! C, > 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

4.
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...
- A: [user:Errichto,2019-01-05] - B: [user:dorijanlendvaj,2019-01-05] - C: [user:Um_nik,2019-01, -to-solvers! - A: [user:Errichto,2019-01-05] - B: [user:dorijanlendvaj,2019-01-05] -C

Full text and comments »

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

5.
By MikeMirzayanov, 9 years ago, translation, In English
New: Diagnostics of Solutions in C++ <img src = "/predownloaded/b5/d2/b5d246ffc32dfe82c3cbac77d1898c5fcb62fa57.jpg" style = "float: right; margin: 0 1em 1em 1em;"/> Hello! I am pleased to report that two rounds of Codeforces have gone quite well in terms of the work of Codeforces, I am very glad about it. These <s>days</s> nights I spent in a profiler, fixing the code, researching the settings of MariaDB. In addition, I managed to allocate several hours on Sunday (to be honest, until Monday morning) to finish the long-planned innovation. Meet, diagnostics of solutions in C++! Many Codeforces visitors are already tired of the questions of less experienced participants: "Why does my solution not work on some test on the Codeforces servers, if I locally launch it and it works correctly? You have the wrong compiler/servers!" In 99% of cases this is an example of <a href ="https://en.wikipedia.org/wiki/Undefined_behavior">undefined behavior</a> in a program. In other words, the program contains mistakes that, du...
New: Diagnostics of Solutions in C++, Новое: Диагностика решений на C++, * written in C++, * finishes with a verdict "wrong answer" or "runtime error" * on this test, * написано на C++, * упало с вердиктом «неправильный ответ» или «ошибка исполнения», * на этом, Meet, diagnostics of solutions in C++!, то оно будет перезапущено, используя специальные диагностические компиляторы (clang++c sanitizers

Full text and comments »

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

6.
By MikeMirzayanov, 7 years ago, In English
Codeforces: С++17 64bit Support Hello, Codeforces. I hope you wash your hands and feel great. I added the support of 64-bit g++. If you are using Windows, you can easily install it via our minimalistic package manager [PBOX](http://pbox.me/) running the command line `pbox install msys2-mingw64-9`. Your solutions are compiled with the command line `g++ -static -DONLINE_JUDGE -Wl,--stack=268435456 -O2 -std=c++17 program.cpp`. Now you can try to use int128 and other 64-bit specific features! In fact, I am slightly worried that the presence of such features may widen the gap between C ++ and other languages. Wait and see. Currently, support for 64-bit C++ is experimental. For example, I would not be surprised if IO on it works slower in some cases (it is necessary to test!). I invite you to join the testing and experimentations. Share your impressions in the comments!
-O2 -std=c++17 program.cpp`., compiled with the command line `g++ -static -DONLINE_JUDGE -Wl,--stack=268435456 -O2 -std=c++17, that the presence of such features may widen the gap between C ++ and other languages. Wait and see., Currently, support for 64-bit C++ is experimental. For example, I would not be surprised if IO on

Full text and comments »

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

7.
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...
C++ Tricks, b = 8 c = 9 ~~~~~ This function helps a lot in debugging. #### 6. Here is C++0x in CF, why, #### 6. Here is C++0x in CF, why still C++?, #### 7. C++0x Strings, Also there is another great feature of C++11, lambda functions!, In C++14 you can also use `auto sum(T a, Args... args)` in order to get sum of mixed types. (Thanks, Variadic functions also belong to C++11 or C++0x, In this section I want to show you some great, You already know literals from C++ like: `0xA`, `1000ll`, `3.14f` and so on..., You don't need to name the type you want to use, C++11 can infer it for you. If you need to loop, [This](http://codeforces.me/blog/entry/10124) is a great C++11 tutorial for those who want to know, int main() { int a = 4, b = 8, c = 9; error(a, b, c); } ~~~~~, int main(){ int a,b,c; tie(a,b,c) = mt(1,2,3); // assign tie(a,b) = mt(b,a); // swap(a,b), ~~~~~ Dear Programmer, I'm using C++11 Regards, Swift! ~~~~~, ~~~~~ a = 4 b = 8 c = 9 ~~~~~, ~~~~~ string r_str = R"(Dear Programmers, I'm using C++11 Regards, Swift!)"; cout << r_str; ~~~~~

Full text and comments »

  • Vote: I like it
  • +971
  • 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...
assign $0$ to $c$. Then we have to assign $1$ to $a$. So there is a problem... At first glance, it, have to assign $0$ to $c$. Then we have to assign $1$ to $a$. So there is a problem... At first

Full text and comments »

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

9.
By maspy, history, 3 months ago, In English
0 Problems Remaining [日本語記事(For Japanese Speakers)](https://maspypy.com/codeforces-all-ac) ---- Previous post: https://codeforces.me/blog/entry/150057 Submission: [submission:384239819] 2026/07/26 03:13:42 JST (2026/07/25 18:13:42 UTC) I have solved every problem in the Codeforces PROBLEMSET except for those for which I determined that obtaining an accepted verdict is impossible. ![unsolved problem list](https://maspypy.com/wp-content/uploads/2026/07/problemset.png) # Scope I considered the problems listed in the [PROBLEMSET](https://codeforces.me/problemset). I have solved very few problems from the [GYM](https://codeforces.me/gyms). The only collection I worked through systematically was the PROBLEMSET. I determined that it is theoretically impossible to obtain an accepted verdict for the following 31 problems: [problem:775A], ([92101](https://codeforces.me/problemset/problem/921/01) ... [92114](https://codeforces.me/problemset/problem/921/14)), [problem:927A], [prob...
implementations written in C++ or another language into the required language. Doing this during a, translate implementations written in C++ or another language into the required language. Doing this

Full text and comments »

  • Vote: I like it
  • +1749
  • 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 ...
that solved this issue: C++ STL's set. It actually hides a monstrous data structure inside, but thanks, What to do with this situation? There is a great example that solved this issue: C++ STL's set, for (int i = 0; i < n + m - 1; i++) { printf("%lld ", c[i]); } printf("\n");, vector c = convolution(a, b);

Full text and comments »

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

11.
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, ). A just-so-so round. Problem E<C imo. According to feecle6418, this round also has a known problem, /122075). No fatal problems occurred in the round, but it feels like Div1A=B=C =D for me :( And actually

Full text and comments »

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

12.
By TLE, history, 8 years ago, In English
Linear Recurrence and Berlekamp-Massey Algorithm **#IjustWantContribution** It seems there isn't any blog about Berlekamp-Massey Algorithm around here, so I decided to go on a try. :P Acknowledgement: Hats off to matthew99 for introducing this algorithm. #### What is 'linear recurrence'? Assuming there is a (probably infinity) sequence $a_0,a_1...a_{n-1}$, we call this sequence satisfies a linear recurrence relation $p_1,p_2...p_m$, iff $\forall i \geq m,~a_i=\sum_{j=1}^m a_{i-j}p_j$. (Obviously, if $m\geq n$ any $p$ can do :P) #### How to calculate k-th term of a linear recurrence? For a polynomial $f(x)=\sum_{i=0}^{t} c_ix^i$, we define $G(f)=\sum_{i=0}^{t} c_ia_i$. Obviously $G$ satisfies $G(f)\pm G(g) =G(f \pm g)$. Because $a_i=\sum_{j=1}^m a_{i-j}p_j$, if we let $f(x)=x^m-\sum_{j=1}^m x^{m-j}p_j$, then $G(f)=0$. Also $G(fx),G(fx^2)...=0$. So $G(fg)=0$ (g is any polynomial). What we want is $G(x^k)$. Because $G(f\lfloor x^k/f\rfloor)=0$, then $G(x^k)=G(x^k \bmod f)$. [cut] We can calculate $x^k \b...
```C++ #include using namespace std; #define, division, the modulus needs to be a prime. ```C++ #include, $, then $A=AP+A_0$ ($A_0$ depends on the first terms of $a$), then $A=A_0/(1-P)$. Moreover, if $A=B/C

Full text and comments »

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

13.
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...
C++20 Is Released, -Wconversion -static -DONLINE_JUDGE -Wl,--stack=268435456 -O2 -std=c++20 `. The only differences are, `pbox install gcc11-64-winlibs`. Probably, a good idea is to add `C :\Programs\gcc11-64-winlibs\bin` into, C++ distribution for the efficiency of reading and writing large amounts of data. For example, the, Hello, Codeforces. Please, welcome c++20 support on Codeforces. Yes, it is 64-bit. Thanks to, Now you can use c++20 in your solutions. I'm not sure there are many features useful in competitive, Please, welcome c++20 support on Codeforces. Yes, it is 64-bit. Thanks to Brecht Sanders: I used

Full text and comments »

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

14.
By NXIST_buster, history, 5 years ago, In English
Corruption, Cheating at ICPC Yinchuan This blog is about Corruption and Cheating at ICPC YinchuanRegional. ICPC Yinchuan Regional is one of the ICPC regional contests for students competing in the geographic area of Asia East Continent. I. Background: General Info ------------------ Ningxia Institute of Science of Technology, or NXIST is a higher education institute in China. Since 2019, NXIST has held two regional contests. The and both were considered by many participants as jokes, yet until today participants are unaware of the NXIST's extent of evil. Zhihu is a Chinese website similar to Quora, and I will refer to this website for information. II. Background: Before 2021 ------------------ Regional competitions in China consists of two stages: The online selection contest and the onsite regional contest. As there are many contestants in China, the online contest is considered serious and rules are usually strictly enforced, with entire universities where some participant cheats disqualified from attend...
*Dr*. *C J Hwang*, ACM-ICPC Asia Director later ordered NXIST to allow all universities interested, I have reported to Dr. C J Hwang, ICPC Asia Director and ICPC headquarters about this matter.

Full text and comments »

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

15.
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...
calculus, you will recognize that if we integrate both sides, we get $\ln B(x) = e^{x} +c$. Since $b_{0}=1, graphs on $n$ vertices (call the count $c_{n}$ and EGF $C(x)$). However this is easy, since each, #### Addition For both OGF and EGF, $C(x)=A(x)+B(x)$ generates the sequence $c_{n}=a_{n}+b_{n}$., #### Shifting For OGF, $C(x) = x^{k}A(x)$ generates the sequence $c_{n}=a_{n-k}$ where $a_{i}=0, $ and $G(x)$ as the EGF of $g$. Using the same function $C$ in the previous problems, we need to find, $C(x,y) = \displaystyle\sum_{n \ge 0}\frac{y^{n}}{n!}\displaystyle\sum_{a_{1}+2a_{2}+...=n,a_{i, $C(x,y) = \left(\displaystyle\sum_{a_{1} \ge 0}\frac{(yx_{1})^{a_{1}}}{a_{1}!1^{a_{1}}}\right)\left, **Example.** The binomial coefficients $c(n,k)$ is defined by the recurrences $f(n,0)=1$ for $n \ge, , we have $D(x) = \exp(C(x))$ using the exponential argument. Thus, $D(x) = \exp(C(x)) = \exp\left, . 2 C. However, why stop here? Suppose the problem asks you to find $b_{n}$ for $n \le 3 \cdot 10^{5, For EGF, $C(x) = A^{(k)}(x)$ generates the sequence $c_{n} = a_{n+k}$, where $A^{(k)}(x)$ denotes, For EGF, $C(x)=A(x)B(x)$ generates the sequence $c_{n} = \displaystyle\sum_{k=0}^{n}\binom{n}{k}a_, For EGF, $C(x)=A(x)^{k}$ generates the sequence $c_{n} = \displaystyle\sum_{i_{1}+i_{2}+...+i_{k}=n, For OGF, $C(x) = \frac{A(x) - (a_{0} + a_{1}x + a_{2}x^2 + ... + a_{k-1}x^{k-1})}{x^{k}}$ generates, For OGF, $C(x)=A(x)B(x)$ generates the sequence $c_{n} = \displaystyle\sum_{k=0}^{n}a_{k}b_{n-k}$., For OGF, $C(x)=A(x)^{k}$ generates the sequence $c_{n} = \displaystyle\sum_{i_{1}+i_{2}+...+i_{k}=n, For both OGF and EGF, $C(x) = xC'(x)$ generates the sequence $c_{n}=na_{n}$., From our discussion above, we know how to find $c(a)$, thus we can write $C (x,y)$ as, Hence, $C(x) = \frac{1-\sqrt{1-4x}}{2x} = \frac{1}{2x}\left[1 - 1 - \displaystyle\sum_{n \ge 1, Hence, we have $C(x)-1=xC(x)^{2}$, which is a quadratic equation in $C(x)$! Using the quadratic, How do we interpret the RHS? We claim that it is $xC(x)^{2}$. Consider the expansion of $C(x)^2, However, $C(x) = \displaystyle\sum_{k \ge 1}\frac{(k-1)!}{k!}x^{k} = \displaystyle\sum_{k \ge 1, Let $c(a)$ denote the number of permutations of length $n = a_{1}+2a_{2}+...$ with cycle type $a, Let $c_{n} = (n-1)!$ be the number of permutations of length $n$ which is a cycle. Let $C(x, Our first step is to look for a recurrence relation. Suppose you have this as a Div. 2C problem, The LHS is easy to intepret: it is just $C(x) - 1$., This time, we need to find $[x^{n}]\displaystyle\sum_{k \ge 0}\frac{1}{k!}C (x)^{k} = [x^{n}]\exp(C, We have shown before that the OGF of the Catalan numbers is $C(x) = \frac{1 - \sqrt{1-4x}}{2x, {k}=n}\frac{c_{a_{1}}c_{a_{2}}...c_{a_{k}}}{a_{1}!a_{2}!...a_{k}!}$ is $[x^{n}]C (x)^{k}$, so $F(x, }+a_{1}+...+a_{n}$. Then, we can take $C(x) = \frac{1}{1-x}A(x)$.

Full text and comments »

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

16.
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...

Full text and comments »

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

17.
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]...
C: [user:Not-Afraid,2020-10-17]

Full text and comments »

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

18.
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>Соревнование открыто для всех в виде отдельных ...
> | Группа языков | Языки программирования / компиляторы | Примеры | |-|-|-| | C | GNUC, GNU C11, | Группа языков | Языки программирования / компиляторы | Примеры | |-|-|-| | C | GNUC, GNU C11

Full text and comments »

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

19.
By MikeMirzayanov, history, 7 years ago, In English
Новое: Диагностика решений на C++ (улучшено отображение) Привет, Codeforces! Вы же помните мой пост <a href="/blog/entry/55902">Новое: Диагностика решений на C++</a>? Если нет, пожалуйста, прочтите его. Совсем недавно я реализовал улучшенное отображение диагностики. Теперь на страницах со списком попыток (статус) вы иногда можете заменить вот такое нововведение: ![ ](/predownloaded/50/05/5005f38b3de6faeb791c08c7d8208de67c92d3d2.png) По нажатию на значок ![ ](https://sta.codeforces.com/s/95227/images/icons/attention-16x16.png) вы увидите код с выделенной проблемной строкой и описание возможной ошибки. ![ ](/predownloaded/32/bc/32bc1c0bbdfe04b0bec5b238acc6fac50788ce27.png) Как вам?
New: Diagnostics of Solutions in C++ (Better UI), Новое: Диагностика решений на C++ (улучшено отображение), решений на C++? Если нет, пожалуйста, прочтите его. Совсем недавно я реализовал улучшенное, Do you remember my post New: Diagnostics of Solutions in C++ <>? If, Hello, Do you remember my post New: Diagnostics of Solutions in C <>, Вы же помните мой пост Новое: Диагностика решений на C++ <>? Если нет

Full text and comments »

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

20.
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...
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

21.
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...
A: [user:alexwice,2023-06-25] B: [user:ksun48,2023-06-25] C: [user:PinkieRabbit,2023-06-25

Full text and comments »

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

22.
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++ tips and tricks, `memset`. It's quite fast and can be used to fill some (usually 1-dimensional) C-arrays by zeroes and, `readLong()`, `readToken()` and so on. I understand that this may be for the sake of similarity withC, function in C++) which does so., variadic template in your, well, template, to call something like `min(a, b, c , ...)`, but you may do this, , I hope a lot of you will find something useful here. C++, as every other language (programming or, Hello, codeforces. I would like to tell you about some tricks and constructions I use inC, I would like to tell you about some tricks and constructions I use in C++. They are not hidden or, This is possible since C++17., ```[c++] #define all(x) (x).begin(), (x).end() ```, ```[c++] auto choose2 = [&](int n) -> long long { if (n <= 1) { return 0, ```[c++] auto choose2 = [&](int n) { if (n <= 1) { return 0; } else, ```[c++] bool has(const vector& vec, int key) { int l = 0, r = vec.size(); while (r, ```[c++] cout << bitset<20>(n) << "\n"; ```, ```[c++] fill(all(vec), 1); ```, ```[c++] for (auto& [x, y] : pts) { cin >> x >> y; } ```, ```[c++] for (int i = 0; i < (int)pts.size(); ++i) { cin >> pts[i].x >> pts[i].y; } ```, ```[c++] for (int i = 0; i < (int)pts.size(); ++i) { pts[i] = {nxt(), nxt()}; } ```, ```[c++] for (int i = 0; i < (int)vec.size() - 1; ++i) { swap(vec[i], vec[i + 1]); } ```, ```[c++] for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { pref[i + 1][j, ```[c++] for (int v = n - 1; v > 0; --v) { int i = 0, j = 0; while (i < (int)nodes[2 * v, ```[c++] for (int v = n - 1; v > 0; --v) { nodes[v].resize(nodes[2 * v].size() + nodes[2 * v, ```[c++] function choose2 = [&](int n) { if (n <= 1) { return 0, ```[c++] generate(all(vec), rand); ```, ```[c++] generate(vec.begin(), vec.begin() + n, nxt); ```, ```[c++] generate_n(vec.begin(), n, nxt); ```, ```[c++] if (S.count(key)) { // ... } ```, ```[c++] if (S.find(key) != S.end()) { // ... } ```, ```[c++] if (binary_search(all(vec), key)) { // ... } ```, ```[c++] if (int x = f(); is_good(x)) { use_somehow(x); } ```, ```[c++] if (is_good(f())) { use_somehow(f()); } ```, ```[c++] int n = nxt(), m = nxt(); for (int i = 0; i < m; ++i) { int u = nxt() - 1, v = nxt, ```[c++] int n = nxt(); vector a(n); generate(all(a), nxt); ```, ```[c++] int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) { int u, v; cin >> u, ```[c++] int n; vector parent, rank;, ```[c++] int nxt() { int x; cin >> x; return x; } ```, ```[c++] int pos = partition_point(all(vec), p) - vec.begin(); ```, ```[c++] int x = f(); if (is_good(x)) { use_somehow(x); } ```, ```[c++] int x = min(min(a, b), c); ```, ```[c++] int x = min(min(min(a, b), c), d); ```, ```[c++] int x = min({a, b, c, d}); ```, ```[c++] rotate(vec.begin(), vec.begin() + k, vec.end()); ```, ```[c++] set S(all(a)); ```, ```[c++] set S; for (int x : a) { S.insert(x); } ```, ```[c++] sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin()); ```, ```[c++] vector a(nxt()); generate(all(a), nxt); ```, ```[c++] vector getConvexHull(vector pts) { int min_pos = min_element(all(pts, ```[c++] void show_binary(int n) { for (int i = 0; i < 20; ++i) { cout << !!(n & (1, ```[c++] { int x = f(); if (is_good(x)) { use_somehow(x); } } ```, or at least in the following C++17 way:

Full text and comments »

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

23.
By EvenImage, history, 6 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 ...
can solve this equation by D&C and FFT in $O(n\log^2 n)$. But there is a slower solution in, of the weight of all the subsequences of $c$ with length $k=1, 2, \dots, n$., something like $P(H)\cdot A=(P(H))' \cdot B+(P(H))'' \cdot C$, where $A,B,C$ are three polynomials, ####[Dirichlet $k$-th root](https://codeforces.me/gym/102471/problem/C) in EC Final By, ))$ when $F$ is D-finite. We can construct the ODE of $F(G(x))$ and solve the equation using D&C and

Full text and comments »

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

24.
By MikeMirzayanov, history, 2 years ago, In English
Welcome GNU G++23 14.2 (64 bit, msys2) <i><b>UPDATE:</b> Some time ago, there was news here that we supported C++23 by installing GCC 14 from the Winlibs project. It turned out that with this method of supporting C++23, some compatibility issues lead to significant performance drops in certain submissions. So, I tried another distribution for GCC 14: the MSYS2 project. It seems that this problem does not occur with it, and now there are no unexpected performance drops. Let's test this C++23 support option together!</i> Hello, Codeforces! Together with [user:Vladosiya,2024-08-22], we've added support for the 64-bit g++14 C++23. You can find it under the name `GNU G++23 14.2 (64 bit, msys2)`. If you're using Windows, you can easily install it via our minimalistic package manager, PBOX, by running the command `pbox install gcc14-64-msys2`. Thanks to the MSYS2 project! We used the distribution from the official package manager. Your solutions will be compiled using the following command line: `g++ -Wall -Wextra -...
-static -DONLINE_JUDGE -Wl,--stack=268435456 -O2 -std=c++23 program.cpp -lstdc++exp`., Now you can start using C++23 features!, Together with [user:Vladosiya,2024-08-22], we've added support for the 64-bit g++14C++23. You can, UPDATE: Some time ago, there was news here that we supported C++23 by installing GCC 14

Full text and comments »

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

25.
By parveen1981, history, 5 years ago, In English
I compiled a list of almost all useful blogs ever published on Codeforces [update: till 09.06.2021] <h3 style="color:red">If there are any blogs that I have missed, please tell in the comment section. Thank you.</h3> # Mathematics Stuff - [Number Theory in Competitive Programming [Tutorial]](https://codeforces.me/blog/entry/46620) - [Number of points on Convex hull with lattice points](https://codeforces.me/blog/entry/62183) - [FFT, big modulos, precision errors.](https://codeforces.me/blog/entry/48465) - [Number of ways between two vertices](https://codeforces.me/blog/entry/19078) - [Mathematics For Competitive Programming](https://codeforces.me/blog/entry/76938) - [FFT and NTT](https://codeforces.me/blog/entry/19862) - [Burnside Lemma](https://codeforces.me/blog/entry/51272) - [Number of positive integral solutions of equation 1/x+1/y=1/n!](https://codeforces.me/blog/entry/76836) - [On burnside (again)](https://codeforces.me/blog/entry/64860) - [Simple but often unknown theorems/lemmas/formula? Do you know?](https://codeforces.me/blog/entry/55912) - [Probabili...
Efficient (and quite common) Way to Navigate Grid Problems [C ++]](https://codeforces.me/blog/entry/78827, suffix automaton (and tree)](https://codeforces.me/blog/entry/22420) - [[C++] basic_string](https, ://codeforces.com/blog/entry/22420) - [[C++] basic_string](https://codeforces.me/blog/entry/62420) - [Aho

Full text and comments »

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

26.
By neal, 8 years ago, In English
Don't use rand(): a guide to random number generators in C++ Don't use `rand()`. Why? Let's jump right into some code. What value will the following code print, approximately? ~~~~~ #include <cstdlib> #include <iostream> using namespace std; const int ITERATIONS = 1e7; int main() { double sum = 0; for (int i = 0; i < ITERATIONS; i++) sum += rand() % 1000000; cout << "Average value: " << sum / ITERATIONS << '\n'; } ~~~~~ Should be about 500,000, right? Turns out it depends on the compiler, and on Codeforces it prints 16382, which isn't even close. [Try it out yourself](http://codeforces.me/contest/1025/customtest). ### What's happening here? If you look up [C++ documentation on `rand()`](https://en.cppreference.com/w/cpp/numeric/random/rand), you'll see that it returns "a pseudo-random integral value between `0` and `RAND_MAX`." [Click again on `RAND_MAX`](https://en.cppreference.com/w/cpp/numeric/random/RAND_MAX) and you'll see that "This value is implementation dependent. It's guaranteed that th...
Don't use rand(): a guide to random number generators in C++, ### What's happening here? If you look up [C++ documentation on `rand()`](https, ### What's the solution? Don't worry, as of C++11 there are **much better** random number, /customtest). ### What's happening here? If you look up [C++ documentation on `rand()`](https, C++11 also gives you some nifty [distributions](https://en.cppreference.com/w/cpp/numeric/random

Full text and comments »

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

27.
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 A and B](https://www.youtube.com/watch?v=KJVigs8w-gg) - [Problem C ](https

Full text and comments »

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

28.
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

29.
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...
The algorithm has exactly the form as seen above, thus its complexity is $O(C \logC)$, where $C

Full text and comments »

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

30.
By ATSTNG, history, 7 years ago, In English
[Tutorial] Matroid intersection in simple words **[This article is also available in [Russian](https://codeforces.me/blog/entry/69287?locale=ru)]** Hello, CodeForces. I think that matroids are beautiful and powerful concept, however, not really well known in competitive programming. I’ve discovered matroids at 2019 Petrozavodsk Winter Training Camp. There was a problem that clearly cannot be solved using usual techniques I knew, editorial for this problem was just these three words “just matroid intersection”. Back then it took me more than 2 days of upsolving to find all the information and details I need and implement solution that gets Accepted on this. And it took way longer to actually understand why does it work and exactly how does it work. (I still hesitate in some details.) Of course, it is not hard to google up all the definitions and some related articles, but in my opinion they all are focused more on mathematical part of theory, strict proofs in some not really obvious but short ways, and observing only ke...
in $D_M (S)$. So, we are looking for some circuit $C$ to be formed in result of exchanges. We are, множество следуя ребрам в $D_M (S)$. Так, нам нужен какой-то цикл $C$, который бы сформировался в, void prepare_colorful_oracle() { for (int c = 0; c < color_count; c++) { color_used[c

Full text and comments »

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

31.
By lotusblume, 14 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 \rightarrowc \rightarrow d, the same behavior with high probability. Assume you have a vertex $a$ with two neighbors $b$ and $c

Full text and comments »

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

32.
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...
Slowdown bug affecting C++ (64 bit) on Codeforces, **Remark**: I'm no longer to reproduce the issue in [Inconsistent times and TLE withC++17 (64bit, . Take a random AC C++ submission that uses `std::cin`. 3. Add the line `vector > TLE, 1. Submitted using 64 bit C++ on Codeforces., [Inconsistent times and TLE with C++17 (64bit) vs. C ++17](https://codeforces.me/blog/entry/91474, [Strange TLE by cin using GNU C++20 (64), and some weird subtle changes to (surprisingly) fix it

Full text and comments »

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

33.
By adamant, history, 17 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...
$$ |C'-C|^2 = \sum\limits_i |C'_i-C_i|^2 \leq \sum\limits_i \delta^2 \log^2 n = n \delta^2 \log^2, $$\begin{gather*} \begin{pmatrix}a \\ b \\ c \\ d \end{pmatrix} \mapsto \begin{pmatrix} a + \omega, ; - Duplicate computations in `double` and `__float128` to track their precision; - Estimate $|C'-C, Do you see why this is helpful yet? If we know $C(x) \equiv P(x) \pmod{x^n+1}$ and $C(x) \equiv Q(x, a = b + 1; /* a = b + {1,1,1,1}; */ a = 2 * b; /* a = {2,2,2,2} * b; */ c = a + b; /*c, meaning that we can estimate $|C'-C| \leq \delta \sqrt n \log n$ instead of $\delta n \log n, v4si a, b, c;, where $k = \lceil \log_4 n \rceil$. The next step in FFT is to find $C'$, the Hadamard (i.e, |$ is the Hadamard product of $A'$ and $B'$. In our estimates above, we figured out that $|C'-C|_1

Full text and comments »

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

34.
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

Full text and comments »

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

35.
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 ...

Full text and comments »

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

36.
By MikeMirzayanov, 9 years ago, translation, In English
Codeforces: Results of 2017 <img src="/predownloaded/e4/09/e40915ee54c5991b91098756a90270d94be893b3.jpg"/> Happy New Year, Codeforces! I hasten to wish the whole community (and including me) correct programs, sudden insights, beautiful ideas and interesting problems! I hope that you have met the new year at least as fun as I am. Have you had enough sleep after New Year's Eve? This year, the traditional post summarizing the past year, I sat down to write only on January 1, 2018. I hope that I will not have to sum up the whole year. This post is important to me, since it draws a line to all the work done by the Codeforces team and the entire community in 2017. Many thanks to the team: all of the achievements listed below are the result of joint efforts. We did an excellent job! The community must know its heroes. In 2017, [user:MikeMirzayanov,2018-01-02], [user:KAN,2018-01-02] (problem coordinator), ~gritukan,2018-01-02 (second problem coordinator), ~netman,2018-01-02 (ex-second problem coordinator), ~k...
, * MemSQL — MemSQL Start [c] UP 3.0, * Playrix — Playrix Codescapes Cup, * Tinkoff Bank, ; Технокубок 2017 и Russian AI Cup 2017, * MemSQL — MemSQL Start[c]UP 3.0, * Playrix — Playrix

Full text and comments »

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

37.
By qwexd, 5 weeks 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...
;">B C

Full text and comments »

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

38.
By Errichto, 8 years ago, In English
Stream I want to try streaming competitive programming. The goal is to make it educational so I will be talking a lot, also answering (at least some) questions. I'm planning three completely different streams to see what format to use: 1. Solving random easy-medium problems. 2. Solving old problems from Polish olympiad. 3. Post-contest stream, assuming I'm a setter or tester of a contest. Similar to what [user:scott_wu,2018-09-27], [user:ecnerwala,2018-09-27] and [user:stevenkplus,2018-09-27] did. Any thoughts, ideas? The first stream will most likely be on Sunday, starting around 7-8pm CEST. I will use Twitch and talk in English only. These first streams should show me and you whether it's cool and useful, and whether I like doing it. Also, I will try to make the video accessible later. **--- UPDATE ---** The first stream will start on Saturday at 10am CEST (check your [timezone](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Errichto+Stream+%231&iso=2018...
://www.twitch.tv/errichto](https://www.twitch.tv/errichto). I will solve some div1 A-C problems, not

Full text and comments »

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

39.
By andreyv, 12 years ago, translation, In English
Ловим глупые ошибки вместе с GCC Как известно, C++ принимает, что программист всегда прав, и поэтому компиляторы C++ не вставляют в программу дополнительные проверки на, например, разыменование нулевого указателя или доступ вне границ массива. У этого есть хорошая сторона: программа на C++ выполняется максимально быстро, и плохая сторона: иногда мы проводим долгое время за отладкой, чтобы в конце найти какую-то глупую ошибку. Хотелось бы, чтобы компилятор подобные ошибки находил сам. И многие компиляторы это могут! В этом посте я расскажу о различных параметрах GCC, которые это делают. Эту тему ранее уже освещал [user:zakharvoit,2015-01-02] в [этой статье](/blog/entry/13875). Все параметры, которые здесь будут приведены, надо добавлять к командной строке GCC. В различных IDE это можно сделать в настройках IDE или компилятора. Многие из параметров можно применять и с Clang (например, в Xcode). Для MSVC++, пожалуй, нет ничего лучше, чем Debug-режим и `/W4`. [cut]   Предупреждения GCC ------------------ Кон...
- `-pedantic` — warns about non-standard C++ language extensions. This way you can eliminate stuff, - `-pedantic` — предупреждает об используемых нестандартных расширениях языка C ++. Таким образом, Кроме самого компилятора, есть ещё стандартная библиотека C/C++. Она тоже позволяет задать

Full text and comments »

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

40.
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...
C: [user:happy.potato,2023-03-26]

Full text and comments »

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