Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

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, 21 month(s) 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 ...
If the result is $x$, then Alice will end the game when Bob moves to a, Since they are very smart, they know the result of the game at the, on the answer $Z$, which is less than $a_1+b_1$, or Alice can end the game immediately to get $a_1, According to [Kőnig's theorem in graph theory ](https://en.wikipedia.org/wiki/K%C5%91nig, Consider the game on the bipartite graph. Initially, we are at cell $(1,1)$. Alice moves first, Let us conclude with the idea of the known game on bipartite graphs., Let us sort $a_i$ and $b_i$ (notice that reordering rows and columns do not change thegame at all, The version of this game where each vertex can be visited exactly once is known. If both players

Full text and comments »

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

2.
By Radewoosh, history, 3 years ago, In English
My opinion on how to practice competitive programming I'm not very often replying to questions about how to practice, but as I'm getting enough of them (and I've just seen another blog about practicing) let me tell you about it. Of course, every time when you ask someone good about how to practice, he/she will reply to you to "solve a lot of problems" and that's true, there's no other way. Anyway, I've thought about it and actually I'm able to tell a bit more. I know some people, I've seen many people practicing (including me) and I have an opinion. Many people practice in some organized way. High schools organize IOI/OI training contests every Saturday, universities organize ICPC training contests once a week, people try by their own to solve three problems each day, websites host rounds and so on. Here's a secret: it's a sh*t. Yep, that's true. If you want to be really good and to make it happen you compete in a training once a week, you do it only to be able to make excuses "but I'm training so hard" when you see no progress. ...

Full text and comments »

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

3.
By Sulfox, 4 years ago, In English
Codeforces Round #635 _Riichi...Tsumo! 2 han 2000 points!_ ![ ](/predownloaded/a9/4f/a94f898a1c9c906cd81ecd483c3ec9ff5e6315c0.png) Hi! Have you ever heard of the game called _Mahjong Soul_? It is a Japanese Mahjong game that is famous for the adorable characters. We are excited to invite you to take part in [Codeforces Round #635](https://codeforces.com/contests/1336,1337), where you can help the characters in trouble. This round will be held on [contest_time:1336]. Most importantly, it is **rated** for both divisions! Each division will be given **6 problems** and you will have **2.5 hours** to solve them. An interactive problem may be found in this round. If you are not familiar with interactive problems, you can learn about them [here](https://codeforces.com/blog/entry/45307). The problems were prepared by [user:EternalAlexander,2020-04-14], [user:ustze,2020-04-14] and me [user:Sooke,2020-04-14]. We sincerely thank [user:isaf27,2020-04-14] for reviewing and coordinating the round, and ...
/a94f898a1c9c906cd81ecd483c3ec9ff5e6315c0.png) Hi! Have you ever heard of the game called _Mahjong Soul_? It is a Japanese Mahjong, Hi! Have you ever heard of the game called _Mahjong Soul_? It is a Japanese Mahjonggame that is

Full text and comments »

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

4.
By Ashishgup, 3 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:...

Full text and comments »

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

5.
By jqdai0815, history, 4 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 ...
You are given a number theory function $g$ and $k$, you need to find a function $f$ such that $g

Full text and comments »

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

6.
By parveen1981, history, 3 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.com/blog/entry/46620) - [Number of points on Convex hull with lattice points](https://codeforces.com/blog/entry/62183) - [FFT, big modulos, precision errors.](https://codeforces.com/blog/entry/48465) - [Number of ways between two vertices](https://codeforces.com/blog/entry/19078) - [Mathematics For Competitive Programming](https://codeforces.com/blog/entry/76938) - [FFT and NTT](https://codeforces.com/blog/entry/19862) - [Burnside Lemma](https://codeforces.com/blog/entry/51272) - [Number of positive integral solutions of equation 1/x+1/y=1/n!](https://codeforces.com/blog/entry/76836) - [On burnside (again)](https://codeforces.com/blog/entry/64860) - [Simple but often unknown theorems/lemmas/formula? Do you know?](https://codeforces.com/blog/entry/55912) - [Probabili...
Based Data Structures in the C++ standard](https://codeforces.com/blog/entry/53520) - [Game Theory, Combinatorial Game Theory](https://codeforces.com/blog/entry/66040) - [An efficient way to solve, # Graphs - [Graph Theory Concepts and Problems.](https://codeforces.com/blog/entry/18585

Full text and comments »

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

7.
By -is-this-fft-, history, 2 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...
This problem is from Moscow Workshops Discover, in heuristic/"proof by AC” algorithms. The idea is to pretend that things in numbertheory are just

Full text and comments »

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

8.
By Anadi, history, 4 years ago, In English
Codeforces Round #647 — Thanks, Algo Muse! Hello Codeforces! We have a pleasure to invite you to [Codeforces Round #647 (Div. 1)](https://codeforces.com/contests/1361) and [Codeforces Round #647 (Div. 2)](https://codeforces.com/contests/1362). This round will take place on [contest_time:1361]. In both divisions, you will have **2.5 hours** to solve **6 problems**. Three of them will be shared. The problems for this round were prepared by [user:MicGor,2020-06-02], [user:Grzmot,2020-06-02], [user:Okrut,2020-06-02] and me. We would like to thank everyone who made this round possible: - [user:Nebuchadnezzar,2020-06-02] for the excellent coordination; - [user:Lewin,2020-06-02], [user:ALILILILILI-KHAN,2020-06-02] for invaluable advice and extensive testing; - [user:KrK,2020-06-02], [user:yarek,2020-06-02], [user:-is-this-fft-,2020-06-02], [user:w0nsh,2020-06-02], [user:Marckess,2020-06-02], [user:Ari,2020-06-02], [user:Fortin,2020-06-02], [user:Dup4,2020-06-02], [user:kraborak,2020-06-02], [user:300iq,2020-06-02], ...
(no coding). It was originally started to help students prepare for theory qualifiers for graduate, pen-and-paper style (no coding). It was originally started to help students prepare fortheory

Full text and comments »

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

9.
By dario2994, 3 years ago, In English
Codeforces Global Round 15 <img src="/predownloaded/2e/e2/2ee2f0f95f05aae6ca6f47812dae2dc2aabf277b.png" style="width:200px; float:right; margin: 0 1em 1em 1em"/> Hi! On [contest_time:1552] we will host [contest:1552]. This is the third round of the 2021 series of [Codeforces Global Rounds](https://codeforces.com/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 2021: - 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 2021 supported the global rounds initiative! Problems for this round ar...

Full text and comments »

Announcement of Codeforces Global Round 15
  • Vote: I like it
  • +823
  • Vote: I do not like it

10.
By ATSTNG, history, 5 years ago, In English
[Tutorial] Matroid intersection in simple words **[This article is also available in [Russian](https://codeforces.com/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...
combination of other vectors from that set). This is the matroid from which whole matroidtheory originates, including all the theory, that is required to construct and prove being optimal algorithm of matroid, matroids. I do not count applications of Rado-Edmonds algorithms and usage of matroidtheory in proofs, need some theory here. Consider some set $S$ that is independent for both matroids $M_1$ and $M_2$ with, opinion they all are focused more on mathematical part of theory, strict proofs in some not really, $. Or say that this is impossible. (Statement involves information about Nim game and Sprague-Grundy, 1. Basics of set theory and set operations 2. Spanning trees in graphs 3. Matchings in bipartite, Now, we have all the theory we need to actually implement a solution for matroid intersection, Surely, you can find all the information in google with queries like “matroid”, “matroidtheory, theory in competitive programming., Разумеется, всю информацию можно найти в google запросами вроде “matroid”, “matroidtheory

Full text and comments »

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

11.
By maomao90, 4 months 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"; } } ...
When does the game end? , wallet. This means that if either of the players still has remaining coins, the game will not end as, The only way that the game ends is when both players have $0$ coins. Since each operation decreases

Full text and comments »

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

12.
By dario2994, 4 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...
which one to attack depending on their taste. Problem *F-Boring Card Game* asks to reconstruct the, Game* asks to reconstruct the moves of a game given the final situation. Even if it looks as one

Full text and comments »

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

13.
By Monogon, history, 3 days ago, In English
[Incoherent Rambling] Optimal strategy in game theory To whom it may concern, Today I was reading some recent problems when I stumbled upon this div2B. [problem:1956B]. At first, it seems like an innocent game theory problem, until I read the following sentence. > Nene is very smart so she always selects cards optimally in order to maximize her score in the end of the game (after $2n$ rounds). If she has several optimal moves, she selects the move that minimizes your score in the end of the game. This struck me as a bit odd, because in most game theory problems on Codeforces, it's a win/lose/draw game, or the player wants to maximize the difference between their score and their opponent's score, or they want to maximize their own score and all outcomes have the same sum of scores for the two opponents (which is equivalent). But Nene's objective is most peculiar, where she doesn't care about how many points her opponent has at all, until she cannot get any more for herself and then it is the only thing she cares about. Now, wha...
[Incoherent Rambling] Optimal strategy in game theory, end of the game (after $2n$ rounds). If she has several optimal moves, she selects the move that, in this game? We seem to take it for granted that it even makes sense to talk about an "optimal, mechanics of the game, you will notice that the sum of scores of the two players is the same in all, simple example game., , it seems like an innocent game theory problem, until I read the following sentence., . [problem:1956B]. At first, it seems like an innocent game theory problem, until I read the, If Bob has a turn: Choice 1: Alice gets 0 points, Bob gets 1 point, game ends. Choice 2: Alice, In most game theory problems on Codeforces, we are dealing with a two-player, zero-sum (or constant, So, what lesson can we take from my incoherent rambling? Mainly, optimal play in game theory is, This struck me as a bit odd, because in most game theory problems on Codeforces, it's a win/lose, ``` Alice goes first. Choice 1: Alice and Bob both get 1 point, game ends. Choice 2: Go to Bob

Full text and comments »

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

14.
By nor, 15 months ago, In English
[Tutorial] A comprehensive guide to permutations for beginners This blog is intended to be an introduction to permutations for beginners, as there seem to be no resources other than cryptic (for beginners) editorials that talk about some cycles/composition, and people unfamiliar with permutations are left wondering what those things are. We'll break the blog into three major parts based on how we most commonly look at permutations. Of course, even though we will treat these approaches separately (though not so much for the last two approaches), in many problems, you might need to use multiple approaches at the same time and maybe even something completely new. Usually, you'd use these ideas in conjunction with something like greedy/DP after you realize the underlying setup. An ordering of the sections in decreasing order of importance according to the current permutations meta would be: cycle decomposition, permutation composition, ordering. However, the topics are introduced in a way so that things make more sense, because there are some...
known to be _simple_ and can be used to show results about the 15-game, for example., very interesting theory, and [this blog](https://codeforces.com/blog/entry/98167) is a good reference, #### Group theory, ) - Group theory - Counting: Burnside, Polya enumeration, Stirling numbers - Coordinate, In the language of graph theory, such graphs are called functional graphs (which have outdegree of, The analysis of a lot of games can be done using group theory, for instance, 15- game, Rubik's cube, We will now switch gears and note a very important part of the theory of permutations — the

Full text and comments »

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

15.
By SlavicG, 2 years ago, In English
How to use Codeforces [GUIDE] I see a lot of newcomers struggling to use the website to it's fullest, so I decided to write a blog that has all important information about how to use Codeforces in a single place. I will update it with time, so feel free to write your suggestions/questions in case I missed something and I will be glad to add it to the post! I would like to thank [user:_Vanilla_,2022-02-05] and [user:mesanu,2022-02-05] for helping me write the blog, and [user:Monogon,2022-02-05], [user:down,2022-02-05] and [user:AlperenT,2022-02-05] for proofreading and giving suggestions. #### Navigating through pages ![ ](https://media.discordapp.net/attachments/705371983650619454/928235498487570442/bandicam_2022-01-05_12-36-00-134.jpg?width=991&height=110) It's possible to navigate through most pages of Codeforces using the bar on the top, I will talk about what each tab does more in depth below: #### The Help Page The help page contains the answer to a lot of questions about Codeforces, such as rati...
consists of "Theory" and "Practice". The Theory part usually consists of a video containing a short, but

Full text and comments »

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

16.
By Endagorion, history, 7 years ago, In English
Yandex.Algorithm 2017, third elimination round: editorial (with challenges, bells and whistles) This time I've decided to play with spoilers to faciliate the presentation as some of the guys here did before. Tell me what you think about this write-up! #### Problem A. Shifts Topics: dynamic programming. Summary: the first "hard" problem of the contest. Knowing your basic DP problems helps a lot, but coming up with the precisely correct solution may take a lot of persistence. Solution: Suppose that we are allowed to make left circular shifts as well as right ones. <spoiler summary="Can you solve the problem in this case?"> First of all, making a shift is effectively moving a character to a different position in the string. Clearly, moving a character more than once makes no sense since we could have just moved it to its final destination instead without wasting any operations. Also, it obvious that the number of occurences of each character should be the same in both strings since it is preserved by shifts. Now, consider the characters that are *not* moved by ...
How to play this game on a unicyclic graph (a connected, players' actions, and $v_R - v_B = n \bmod 2$. It follows that the equivalent game would be to minimize, #### Problem F. Tree Game, Topics: game theory, graphs, math.

Full text and comments »

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

17.
By -Morass-, history, 7 years ago, In English
Problem Topics Good Day to you! I've been asked to make some topic-wise list of problems I've solved. Even though I couldn't involve all problems, I've tried to involve at least "few" problems at each topic I thought up (I'm sorry if I forgot about something "easy"). I've alredy made such list once anyway I've tried to include more problems now &mdash; so here it is: <spoiler summary="aho"> http://www.spoj.com/problems/ADAJOBS/ URI 2226 (5) //[NICE][NUMBERS][DP] http://www.spoj.com/problems/SUB_PROB/en/ http://codeforces.com/contest/696/problem/D 8 http://www.spoj.com/problems/AHOCUR/ 5 //Aho-Corassic + DP https://www.codechef.com/problems/LYRC (5) //Sample aho-brute-force http://codeforces.com/problemset/problem/346/B //Proposed by [user:bradyawn,2019-08-03] </spoiler> <spoiler summary="automat"> 6861 [LA] //CYK UVA 10679 //Suffix Automat http://www.spoj.com/problems/STRMATCH/ //Suffix Automat &mdash; trie might do too http://www.spoj.com/problems/NSUBST...
-problems/algorithm/harry-and-ron-play-a-game-of-chess/, 12530 — Game of Tiles, 7892 — Game of Matchings (6) //No idea — heuristic works — but seems to be nice, DevSkills 475: Bunty's Xor Game (4) //[BITS][GAME THEORY], UVA 11495 //INV [GAME], http://codeforces.com/contest/134/problem/B (4) //Number Theory, http://codeforces.com/contest/88/problem/C (3) //[NUMBER THEORY], http://codeforces.com/contest/893/problem/E (5) //[COMB-NUMBERS][NUMBER-THEORY], http://codeforces.com/gym/101650 [I](5) //[NICE][GRAPHS]// Theory is useful, http://codeforces.com/gym/101992/problem/D (5) //[VERY NICE][IE][NUMBER THEORY], http://www.spoj.com/problems/ADAHW/ [RHO][Number Theory], http://www.spoj.com/problems/PUCMM210/ (3) //Number theory (thinking not necessary), http://www.spoj.com/problems/RIOI_3_2/ (5) //VERY NICE (easy imple — Number Theory thinking), http://www.spoj.com/problems/WAGE/ (3) //Simple Game Of Life Modification, https://codeforces.com/contest/1178/problem/D (4) //[VERY NICE][OBSERVATION][NUMBERTHEORY]

Full text and comments »

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

18.
By cgy4ever, 10 years ago, In English
Codeforces Round #270 Do you want to win a T-shirt? Do you want to learn how to design tasks for programming contest? Do you want to solve 7 tasks in 2.5 hours? So Codeforces Round #270 is right for you. It was designed by me in California, Assembled in polygon (so Thank you [user:MikeMirzayanov,2014-09-26] for the system and [user:Gerald,2014-09-26] for organize and testing), will start on [regular time this Sunday](http://www.timeanddate.com/worldclock/fixedtime.html?day=28&month=9&year=2014&hour=19&min=30&sec=0&p1=166), don't miss it! The organizers of **<a href="/blog/entry/13929">Marathon24</a>** decided to present gifts to the best finishers of the round! Best 25 participants will get Marathon24 tshirts! Thanks! <center> <img src="http://www.elmostshirts.com/images/tshirts.jpg"/> <br><small>It is just an image to attract your attention. Real tshirts will be designed specially for Marathon24!</small> </center> There are some articles introduced how to become a problem setter, like [Pro...
Angeles to learn Game Design and Game Development. As a game designer, I'll try to make my round, Los Angeles to learn Game Design and Game Development. As a game designer, I'll try to make my round

Full text and comments »

Announcement of Codeforces Round 270
  • Vote: I like it
  • +794
  • Vote: I do not like it

19.
By Errichto, 5 years ago, In English
Sums and Expected Value — part 1 part 2: https://codeforces.com/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...
=U_h3IjreRek](https://www.youtube.com/watch?v=U_h3IjreRek). I will go through theory and problems from

Full text and comments »

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

20.
By nor, 15 months ago, In English
[Tutorial] How to learn better, and what most people don't get about learning **Disclaimer:** I am not an expert in the field of the psychology of learning and problem-solving, so take the following with a grain of salt. There is not much "scientific" evidence for this blog, and the following is validated by personal experience and the experiences of people I know (who fall everywhere on the "success" spectrum &mdash; from greys to reds in competitive programming, from beginners in math to IMO gold medalists, and from people with zero research experience to people with monumental publications for their own fields). This blog only covers one possible way of thinking about knowledge organization and retrieval that I have been using for the past decade or so, but there definitely will be other models that might work even better. Even though I just have a few courses worth of formal psychology experience, I still think the content of this blog should be relevant to people involved with problem-solving. I hope this helps both students (to make their learning effic...
first link needs a bit of number theory background, but the arguments are very understandable even, structure - Reading up on theory - Learning via problems - Applying creativity to, ##### Reading up on theory, ** (coloring, graphs) - **Guess first and prove later** (induction) - **Miscellaneoustheory** (theory, . Unless studied properly, theory will almost inevitably lead to prominent concepts (nodes) but weak, Category theory takes this sort of an idea to the extreme, and has a very rich theory that is

Full text and comments »

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

21.
By PrinceOfPersia, 9 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$ ...

Full text and comments »

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

22.
By MinakoKojima, history, 8 years ago, In English
My sad story Teams advancing to 2016 WF Phuket in Asia have been announced recently. This announcement is undisputedly tantamount to a death sentence for me. I am the one waiting anxiously, refresh Dr. Hwang's blog everyday. But it seems that for years, our training was meaningless. I think many of us dedicate our passion to programming contests because we see them transparent, fair and without any corruption. And I also believe that as contestants, what we should do is only focus on the practice. And I thought those political business should never come to bother me one day. But sadly, it is my team who is going to become one of the sacrifices of a succession of the dissension. What happened so far ------------------ The quarrel between the Asia director and the local community is [a long story](http://blog.sina.com.cn/s/blog_b946da100101q21y.html) to tell. But it has never been as serious as it was in the past season. Now reflecting on this, I know on the surface everything is going okay...
acknowledged game rules. There should be no parameters remain to be determined after the contest. I know, be much simplified. There could be bonus slot but shouldn’t affect the acknowledgedgame rules, be much simplified. There could be bonus slots but shouldn’t affect the acknowledgedgame rules

Full text and comments »

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

23.
By cgy4ever, 9 years ago, In English
Codeforces Round #290 Fox Ciel is back! I invite you to participate in Codeforces Round #290, which will start at the [standard time on next Monday](http://www.timeanddate.com/worldclock/fixedtime.html?day=2&month=2&year=2015&hour=19&min=30&sec=0&p1=166): This is my 4th round on Codeforces, my previous rounds: [#190](http://codeforces.com/blog/entry/8163), [#228](http://codeforces.com/blog/entry/10605), [#270](http://codeforces.com/blog/entry/13997). Last Div1 Round ([#286](http://codeforces.com/blog/entry/15842)) is so hard, so after notice that, we decide to reduce the difficulty of this round. (For example, current Div1-E was used as Div1-D) I hope more people can enjoy all tasks in this round: this time no task requires advanced knowledge like linear space or Fourier Transform. The background story will be Fox Ciel's life: learning programming, play games, traveling, have dinner and so on. Like Round [#228](http://codeforces.com/blog/entry/10605), top-20 contestants that are currently at...

Full text and comments »

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

24.
By nor, 16 months ago, In English
Probability 101, the intuition behind martingales and solving problems with them Recently someone asked me to explain how to solve a couple of problems which went like this: "Find the expected time before XYZ happens". Note that here the time to completion is a random variable, and in probability theory, such random variables are called "stopping times" for obvious reasons. It turned out that these problems were solvable using something called martingales which are random processes with nice invariants and a ton of properties. I think a lot of people don't get the intuition behind these topics and why they're so useful. So I hope the following intuitive introduction helps people develop a deeper understanding. Note that in the spirit of clarity, I will only be dealing with finite sets and finite time processes (unless absolutely necessary, and in such cases, the interpretation should be obvious). I will do this because people tend to get lost in the measure-theoretic aspects of the rigor that is needed and skip on the intuition that they should be developing ins...
at every time $t$, a new gambler comes ad pays $1$ to play the game. He reinvests his bet ($|\Sigma, keeps reinvesting all his capital into the game. The game gives a payout of $r$ percent if he wins, make life easier when we try to prove results in math. Secondly, it originated in thetheory of, , and in probability theory, such random variables are called "stopping times" for obvious reasons. It, Suppose we are in the gambler's shoes, and we want to write an algorithm to finish thegame

Full text and comments »

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

25.
By codetiger927, history, 2 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. ...
though this is just a game, you can use the website as a source of motivation since people depend on you, game mechanics can be found on the [about page](https://codetiger.me/project/StonksCF/about.html)

Full text and comments »

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

26.
By ko_osaga, history, 15 months ago, In English
[Tutorial] On Range LIS Queries, Part 1 Hello, Codeforces! At some point of life you want to make a new data structure problem with short statement and genius solution. LIS (Longest Increasing Subsequence) is a classic problem with beautiful solution, so you come up with the following problem: * Given a sequence $A$ of length $N$ and $Q$ queries $1 \le i \le j \le N$, compute the length of Longest Increasing Subsequence of $A[i], A[i + 1], \ldots, A[j]$. But on the other hand this looks impossible to solve, and you just give up the idea. I always thought that the above problem is unsolved (and might be impossible), but very recently I learned that such queries are **solvable** in only $O(N \log^2 N + Q \log N)$ time, not involving any sqrts! The [original paper](https://arxiv.org/abs/0707.3619) describes this technique as *semi-local string comparison*. The paper is incredibly long and uses tons of scary math terminology, but I think I found a relatively easier way to describe this technique, which I will show in...
in comments. (The original paper mention some group theory stuffs, but I have literally zero

Full text and comments »

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

27.
By AkiLotus, 4 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 ...
This round is themed based on the Rayark Inc.'s rhythm game, [_"Cytus II"_](https://www.rayark.com

Full text and comments »

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

28.
By zscoder, history, 4 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.com/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, ...
It is hard to compute when a game ends, and it is also hard to, fractions**. Note that the theory of partial fractions tell us that, state of the $i$-th switch. The game ends when all switches are off. What is the expected number of, Ok, so we can find $a(k)$. Let $c(k)$ denote the probability that the game ends (all switches are

Full text and comments »

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

29.
By tourist, history, 6 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...

Full text and comments »

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

30.
By Everule, history, 2 years ago, In English
Essentials of Elementary Number Theory This is a blog starting from the very basics of number theory, in a way that flows fluidly from one concept to another and is based in developing an intuitive feeling for the basics of elementary number theory. This is not a blog to simply gloss over. I consider more of a guided exploration into the world of discovering things in the world of number theory, and I don't expect anyone to immediately understand all the insights in this blog. But if you put an honest effort into discovering how I find these insights you will find much use for my blog. If you do not know some notation or some elementary theorem I use you should refer to this. <spoiler summary="Elementary definitions"> We start with the basic definition that is at the heart of number theory. Let $a \mid b$ (read a divide(s) b) for some $a,b \in \mathbb{Z}$ for some if there exists $k \in \mathbb{Z}$ such that $b = ak$. Similarly $a \not\mid b$ if there does not exist such $k$. If $g \mid a$, then $g \mid ab$. ...
Essentials of Elementary Number Theory, Theorem"> This function is at the heart of most elementary number theory. $\gcd(x,y)$ is defined as the, of number theory. Let $a \mid b$ (read a divide(s) b) for some $a,b \in \mathbb{Z}$ for some if, This is a blog starting from the very basics of number theory, in a way that flows fluidly from one

Full text and comments »

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

31.
By Um_nik, 5 years ago, In English
How to read problem statements But [user:Um_nik,2018-10-26], we all know how to read, we have our whooping 2 month of experience! Oh, my sweet summer child, my experiments show that many people with kinda cool achievements like medals on ROI don't know how to read statements. But don't worry, I'll teach you. Well, probably you won't understand anything, because you didn't try to understand anything in your life, you expect all hard work to be done for you by someone else. Let's start! Basic rules ================== - The result of reading the statement is usually pure math model. If story helps to build correct understanding, you can keep it, but still try to discard as many unnecessary details as possible. - Imagine you want to tell the problem to someone else. What parts you want to tell? (According to my PM, this rule won't help you). - Shorter = better. - Simpler = better. - Limitations are part of problem statement. Especially small limitations, because for small data you can try all the possib...
white vertices (surprise) red and blue. The game ends when there are no white vertices left. The score, )) \ne 1$. Wow, it is not geometry, it is number theory problem?! Who would know! Except, like, anyone

Full text and comments »

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

32.
By viktork, 9 years ago, translation, In English
ZeptoLab Code Rush 2015 Hello, Codeforces! <b><i>The problems were suggested by users [user:roosephu,2015-04-04] and [user:sunayuki,2015-04-04]. The great help in preparing was provided by [user:Aksenov239,2015-04-04], [user:GlebsHP,2015-04-04] and Codeforces team. ZeptoLab Team did its best while working on statements.</i></b> <b><i>The round will use smoother dynamic problem scores with 250 points steps.</i></b> In 2014 we hosted our [first programming contest](/zeptolab2014) together with Codeforces, and we liked it! Let me shortly remind you how it was. The contest consisted of 6 problems, 2.5 hours were given to solve (you can have a look at the problems of the previous year and try to solve them [here](/contest/436)). Of course, even on a purely coding event we stayed true to ourselves, so all problems were designed based on our games, and, of course, we illustrated them with care: <center> <img src="http://assets.codeforces.com/images/zepto2015/pics2014.jpg"/> </center> Zepto C...
the highlight of the program: of course, the game in a giant Cut The Rope and our standard, to improve packaging of atlases in preparing of > game resources – a well-known NP-hard problem. I, -tour and the highlight of the program: of course, the game in a giant Cut The Rope and our standard

Full text and comments »

Announcement of ZeptoLab Code Rush 2015
  • Vote: I like it
  • +886
  • Vote: I do not like it

33.
By brunovsky, 3 years ago, In English
[Tutorial] Network simplex Hello! If you've learned the simplex algorithm and a minimum cost flow algorithm, perhaps you've also heard about this fancy thing called [network simplex](https://en.wikipedia.org/wiki/Network_simplex_algorithm) which is supposed to be a specialization/optimization of the simplex algorithm for computing a [minimum cost circulation](https://en.wikipedia.org/wiki/Minimum-cost_flow_problem). If your google search didn't turn up any interesting results or your interest faded, you might have moved on to other subjects. Well I didn't! So this is a tutorial on network simplex (NS) for the **minimum cost circulation** problem. I'll describe and formulate the problem, show how it relates to the usual minimum cost flow problem, explain the theory behind the algorithm in-depth, and then derive the implementation details. ## Introduction The algorithm commonly used in competitive programming for this sort of task is a minimum cost flow algorithm based on finding augmenting paths in a *f...
problem, explain the theory behind the algorithm in-depth, and then derive the implementation, programming and the simplex algorithm is needed to follow along in the theory section comfortably., ## Theory

Full text and comments »

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

34.
By -is-this-fft-, history, 20 months 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.com/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...
_can_ mean that in some problems (for example, in game problems with just 2 parameters, you can, other people's thought processes) etc don't work. However there are many people who intheory

Full text and comments »

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

35.
By Lewin, 8 years ago, In English
Wunder Fund Round 2016 Hello Codeforces! I invite all of you to participate in a **special** Codeforces round. It will take place on [29 Jan, 17:05 UTC](http://www.timeanddate.com/worldclock/fixedtime.html?day=29&month=1&year=2016&hour=20&min=5&sec=0&p1=166). It will not be a usual round. Thanks to Wunder Fund, the best participants will win prizes and souvenirs. Here are some words from <a href="http://wunderfund.io/">Wunder Fund</a>: <img src="http://assets.codeforces.com/images/optimization.jpg" style="float:right; margin: 0 1em;"/> > Our company is situated in the center of Moscow. We are engaged in high-frequency trading &mdash; developing high-performance systems and algorithms for automated trading in financial markets. In this area algorithms and data structures (that you love to invent and implement) are vital. Our systems should process transactions in milliseconds! High-frequency trading is a continuous competition of the best programmers and mathematicians around the world. By joining us...

Full text and comments »

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

36.
By adamant, history, 22 months ago, In English
Combinatorial species: An intuition behind generating functions Hi everyone! The usage of generating functions is quite common in competitive programming these days. But it seems to happen so, that they're mostly presented as a way to simplify formal manipulation with polynomial coefficients, rather than something meaningful. But there actually is a meaning to all of this, and today I'm going to shed a light on it. Alongside the blog post we'll uncover the combinatorial meaning of - The addition $F(x)+G(x)$, - The multiplication $F(x)G(x)$, - The exponent $\exp F(x)$, - The logarithm $\log F(x)$, - The sum of the infinite geometric progression $\frac{1}{1-F(x)}=1+F(x)+F^2(x)+\dots$, - The general composition $F(G(x))$ for the generating functions $F(x)$ and $G(x)$ and the underlying structures they represent. ### Prerequisites - Basic notion of set theory (cardinality of sets, mappings, bijections, cartesian product, disjoint union, etc); - Polynomials and formal power series (representation, convolution formula, power seri...
addition of new axioms to the Zermelo-Fraenkel set theory), you may assume that the work is done in the, - Basic notion of set theory (cardinality of sets, mappings, bijections, cartesian product, /0a3333460eba3578b8764ee4266fd9b1a2646571.svg" width="400px"> In category theory terms, a combinatorial species is a , /5664582aab8cbe0e47094588728842ad7f189b7f.svg" width="400px"> In category theory terms, the mapping $\alpha$ is a , Although combinatorial species are defined with category theory concepts, I will try to avoid them

Full text and comments »

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

37.
By BledDest, history, 6 years ago, translation, In English
Educational Codeforces Round 33 [Rated for Div. 2] Hello Codeforces! On [November 23, 18:05 MSK](https://www.timeanddate.com/worldclock/fixedtime.html?day=9&month=11&year=2017&hour=18&min=5&sec=0&p1=166) Educational Codeforces Round 33 will start. Series of Educational Rounds continue being held as [Harbour.Space University](https://harbour.space/) initiative! You can read the details about the cooperation between [Harbour.Space University](https://harbour.space/) and Codeforces in the <a href="http://codeforces.com/blog/entry/51208">blog post</a>. As an experiment, the round will be **rated for Div. 2**. It will be held on extented ACM ICPC rules. After the end of the contest you will have one day to hack any solution you want. You will have access to copy any solution and test it locally. You will be given **6 problems** and **2 hours** to solve them. The problems were prepared by Mikhail [user:PikMike,2017-11-08] Piklyaev, Vladimir [user:0n25,2017-11-22] Petrov and me. Good luck to all participants! UPD: [Edito...
Oxford, Department of Computer Science. She researches game theory and the computation of social, 30.04.18 — 18.05.18 — Probability theory with Evgeniy Riabenko

Full text and comments »

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

38.
By Zhtluo, history, 7 weeks ago, In English
All You Need is Randomly Guessing — How to Improve at Codeforces I hope [my previous blog](https://codeforces.com/blog/entry/126310) has convinced you that the best way to improve at Codeforces is to be more Russian, i.e. to improve your math capability. Unfortunately, humble mortals such as you and I are not gifted with the talent that esteemed Russian grandmasters such as 74TrAkToR had: _Surely, it is beneficial to have a code reference for many algorithms and data structures, but I also think that just superficially knowing the algorithm and maybe having implemented it once or twice before is sufficient to use it without a reference?_ _&mdash; Some other Codeforces grandmaster_ Therefore, in this blog I will explore the dark side of Russian-ness &mdash; randomly guessing &mdash; that is forsaken by every Russian grandmaster of the light side I know. However, it has been very helpful to me, and I hope that it serves you well, too. ## Example 1 I will start by using an example to demonstrate my thought process. This problem [1923C](h...
code the solution out, which motivates me to develop a theory on guessing., ### Theory on Guessing, #### Some Learning Theory, #### Some Theory on Reasoning, theory, logic is categorized into three parts.

Full text and comments »

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

39.
By Shisuko, history, 5 years ago, In English
The Intuition Behind NIM and Grundy Numbers in Combinatorial Game Theory There are already many wonderful resources online for learning the basics to combinatorial game theory, but the intention I have for _this_ guide in particular is to try to make them more intuitive. Why does XOR work for Nim? Why does mex produce the Grundy numbers? When it was taught to me, it was more or less just as 'magic' to memorize, but now I think I have a decent understanding of why they are true, so now that I have a grasp of the intuition behind it, I decided I should record my thoughts into a blog. Nim games ================== Suppose we are playing a Nim game. As we know, Nim games usually follow this sort of template: - There are $n$ piles of stones, and each pile contains $p_1, p_2, p_3, \cdots p_n$ stones, where each of the $p_i$ is some nonnegative integer. This collection of piles defines our game state. - There are two players who take turns removing stones. The current turn player may remove as many stones as they wish, so long as all the stones come f...
The Intuition Behind NIM and Grundy Numbers in Combinatorial Game Theory, $p$. Each vertex corresponds to some game state, where its label indicates how many stones are in, be true since if you place an empty pile next to an existing game, you should still effectively have, blatantly about Game Theory that I hope it's okay. (Non-comprehensive) Problems that use Nim and, called the **Nim-sums** of the game state. However most of what I gave consists of heuristics and, each of the $p_i$ is some nonnegative integer. This collection of piles defines ourgame state., forums, but these problems are so blatantly about Game Theory that I hope it's okay., general, and says that *any impartial combinatorial game* is essentially Nim, due to the Grundy numbers, graph, i.e. the game ends in a finite number of moves., greater than $g$. Consider in the square number game earlier, if we have a pile of size 5 and we take, number of stones in them, let's say that the Nim-value of a game that consists of only a single pile is, pile in our game was transformed from having $p$ stones but with weird rules, to having $G(p)=g, turn. There are only a finite number of moves in a game of Nim (obvious, but you can prove it by, winning game state when $G>0$, and corresponds to a losing game state when $G=0$., **Given a game of Nim whose current game state consists of $n$ piles with $p_1, p_2, p_3, \cdots, , 6$ are $0, 1, 0, 1, 2, 0, 1$, respectively. You can verify this. Therefore, if we have agame state, , meanwhile, can just play the game like normal Nim, only deviating from the strategy to undo any, , such as the Nim game where you can only take a square number of stones from a pile. If there is a, - $A \oplus A = 0$. That is to say, the inverse of each game state is itself. Think about why this, - For each game state $g$, let us assign to it some integer "Nim-value" $G$ which tells us whether, - Given two game states $a$ and $b$, let $a+b$ be the game state that is simply the piles of $a, - The game ends when there are no stones left on the board. The winner is the one who took the last, - The game state is called a winning state if there exists a winning strategy for it. That is, the, 1. The empty game is a losing state with Nim-sum 0. This follows from our observations earlier., Let us turn back to our original strategy---decompose the game state into several piles, find some, No self-respecting problem-setter would ever give just a vanilla Nim game, though, now that it has, Note that in our normal game of Nim, each state points to every state smaller than it (since taking, Now, let's tackle the simplest possible game---one that consists of a single pile with $p$ stones, Say you are similarly given a game state of $n$ piles with stones $p_1, p_2, p_3, \cdots p_n$. The, Suppose we are playing a Nim game. As we know, Nim games usually follow this sort of template:, The question then usually goes something like this: Given an initial game state $p_1, p_2, p_3, There are already many wonderful resources online for learning the basics to combinatorialgame, There exists a fairly standard $O(n)$ formula to solving the Nim game, though I'm not sure how many

Full text and comments »

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

40.
By PrinceOfPersia, history, 9 years ago, In English
The 1st Hunger Games Hello Codeforces. Hunger games is a programming tournament. For participating in this tournament, you should join as a participant in [this group](http://codeforces.com/group/qcIqFPYhVr) until the [deadline](http://www.timeanddate.com/worldclock/fixedtime.html?day=10&month=8&year=2015&hour=19&min=30&sec=0&p1=166). After the deadline you'll be able to join only as spectator. In some time after the deadline (exact time will be published) tournament starts as a long contest in the group. At first, there will be some problems. Each day, organizers will add a non-negative number of problems to the contest. Also, at the end of each day, a non-negative number of participants from the bottom of the scoreboard will be deleted from the contest (to practice) and become spectators (not able to submit any more). Also, people that don't submit any code in first two-three (exact time will be published) days will become spectators. Finally, there will be 20 peoples remaining at the end. We...

Full text and comments »

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

41.
By Sad_reacts_only, 3 years ago, In English
Changes in Codeforces problem style over 2020 Sorry for my poor English. I am talking only from Div2 perspective as I think Div1 contest are still ok from this point of view. During 2020 codeforces moved from having problems with variation over known algorithms and data structures to constructive heavy contests. I am not saying that having constructive problems are bad but their amount is way too high and I guess most of us will agree that now a days problems on topics like binary search, DP, Graphs or segment tree or other data structures etc are almost extinct in Div2 rounds. Lets take last Div2 [contest:1474] as an example someone who knows programming language and basic number theory could solve problems till E and can get 1st rank. So in theory someone could become a master or International Master with just number theory and programming language knowledge. I used to like constructive problems a lot (Actually one of my stronger topics) but now a days there are just so much constructive problems that they ...
number theory could solve problems till E and can get 1st rank. So in theory someone could become a

Full text and comments »

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

42.
By Um_nik, history, 15 months ago, In English
MIT Mystery Hunt Disclaimer: This blog is not about competitive programming; you probably will not learn anything about algorithms and data structures. In other words, it doesn't qualify for [this initiative](https://codeforces.com/blog/entry/110840), but I want to give a link to it anyways because I think it's cool. I love solving problems. No, seriously. I LOVE it. The mindset described in [this blog](https://codeforces.com/blog/entry/91114) is 100% how I feel. But it is not constrained to competitive programming problems. I loved math problems for a much longer time, and physics was somewhere there. But I also love solving puzzles. And playing puzzle games on the computer (well, on consoles). And participating in intellectual games. I am not as good in them as in cp, but it was never about being good for me, I just love the process. And I think that there might be some people with a similar love for puzzles among competitive programmers, this is why I decided to write this blog on CF <s>and no...

Full text and comments »

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

43.
By pajenegod, history, 10 months ago, In English
Tutorial: A simple O(n log n) polynomial multiplication algorithm Hi Codeforces! I have something exciting to tell you guys about today! I have recently come up with a really neat and simple recursive algorithm for multiplying polynomials in $O(n \log n)$ time. It is so neat and simple that I think it might possibly revolutionize the way that fast polynomial multiplication is taught and coded. You don't need to know anything about FFT to understand and implement this algorithm. Big thanks to [user:nor,2023-07-10], [user:c1729,2023-07-10] and [user:spheniscine,2023-07-10] for discussing the contents of the blog with me and comming up with ideas for how to improve the blog =). I've split this blog up into two parts. The first part is intended for anyone to be able to read and understand. The second part is advanced and goes into a ton of interesting ideas and concepts related to this algorithm. Prerequisite: Polynomial quotient and remainder, see [Wiki article] (https://en.wikipedia.org/wiki/Polynomial_greatest_common_divisor#Euclidean_divi...
#include "../number-theory/ModPow.h"

Full text and comments »

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

44.
By -is-this-fft-, history, 15 months 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.com/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...
**Problem.** (made up educational problem) There is a game that up to $n$ players can play. Players, In this blog, I am going to cover the basic theory and (competitive programming related

Full text and comments »

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

45.
By pajenegod, history, 3 months ago, In English
Shallowest Decomposition Tree Hi Codeforces! Today I want to tell you about a really cool and relatively unknown technique that is reminiscent of Centroid decomposition, but at the same time is also completely different. The most common and well known decomposition tree algorithm out there is the centroid decomposition algorithm (running in $O(n \log n)$). It is a standard algorithm that is commonly used to solve tons of different kind of divide and conquer problems on trees. However, it turns out that there exists another closely related decomposition tree algorithm, that is in a sense optimal, and can be implemented to run in $O(n)$ time in around $30$ lines of code. I have chosen to call it the _Shallowest Decomposition Tree_. This blog will be all about the shallowest decomposition tree. Something I want to remark on before we start is that I did not invent this. However, very few people know about it. So I decided to make this blog in order to teach people about this super cool and relatively unknown tec...
could in theory be using big integers. But as we will see in the next section, Section 3.2, greedy, finding an optimal deterministic strategy in the treasure hunt game, since a solution to the, ## 1.2. The centroid guessing strategy A natural strategy for the treasure hunt game is to guess, ## 1.3. The center guessing strategy Another natural strategy for the treasure huntgame is to, There has also been a much more recent problem [problem:1444E], which is a treasure huntgame on a

Full text and comments »

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

46.
By nor, 5 months ago, In English
[Tutorial] On lambdas, C++ and otherwise: the what, the why, and the how **Disclaimer:** This blog (and all of my other blogs, unless specified otherwise) is 100% ChatGPT-free &mdash; there has been no use of any AI/ML-based application while coming up with the content of this blog. <spoiler summary="The reason and an appeal">There is a lot of AI-generated content out there these days that sounds plausible and useful but is absolute garbage and contributes nothing beyond a list of superficial sentences &mdash; even if it has content that is true (which is a big IF, by the way), it generates content that you could have just looked up on your favorite search engine. The reason why such current AI-generated content is like this is multi-fold, but I won't get into it because I need to write the content of this blog, too, and I don't see copy-pasting this kind of content as anything but a stupid maneuver that wastes everyone's time. I hope other people who write blogs refrain from using this stuff for generating content that is supposed to be meaningful an...
" which has a very different meaning in category theory, so it will irk a lot of people if you call a, Hopefully, this blog will also get people interested in programming language theory &mdash

Full text and comments »

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

47.
By adamant, history, 22 months ago, In English
Nimbers and Sprague-Grundy theorem Hi everyone! Today I'd like to write about the so-called Grundy numbers, or nimbers. I will start by providing a formal recap on the Sprague-Grundy theorem and then will advance to the topic that is rarely covered in competitive programming resources, that is I will write about nimber product and its meaning to the game theory. _I was asked to add the following to the blog: THANK SIR MASTER [user:ADAM_GS,2022-06-12] FOR GREAT AND VALUABLE REVIEW SIR_ ## Prerequisites Familiarity with the following concepts: - Basic [set theory](https://en.wikipedia.org/wiki/Set_theory) notion: [union](https://en.wikipedia.org/wiki/Union_%28set_theory%29), [cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) and [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) of sets, [set of all subsets](https://en.wikipedia.org/wiki/Power_set) denoted as $2^A$, etc; - [Groups](https://en.wikipedia.org/wiki/Group_%28mathematics%29) and [fields](https://en.wiki...
following game:, simple game represented as a directed graph. Losing states are red, winning states are blue., strategy in that game. $\square$, the game theory., "> A move in the diminishing rectangles game. , ## Game sum, ### Game product, $) if for any impartial progressively bounded game $C$, $A+C$ has the same outcome as $B+C$., * $V$ is a set of game _states_; * $\delta : V \mapsto 2^V$ is a _move_ function, meaning that the, **Claim 2**. Every state in the progressively bounded game is either winning or losing., **Claim 6**. For any game $A$, its sum with itself $A+A$ is losing., **Claim 8**. ( _Sprague-Grundy theorem_ ) Every impartial progressively bounded game is equivalent, **Def 2**. An impartial game $G$ is called **winning** if the first player has a winning strategy, **Def. 1**. An **impartial game** is a game that can be represented as a tuple $G=(V, \delta, s, **Def. 10**. The **diminishing rectangles** game is described as follows:, **Def. 11**. The **coin turning** game is described as follows:, **Def. 3**. An impartial game is **progressively bounded** if there is an upper bound for every, **Def. 7**. A **nimber** $x$ of the game $G$ is the size of its one-heap equivalent, that is $G, **Proof**. Second player can symmetrically repeat the moves of the first one in the secondgame, **Proof**. The game in which $\delta(s)=\varnothing$ is equivalent to a game of nim on the heap of, Correspondingly, a _partisan_ game would imply that there are two move functions $\delta_1(v)$ and, Generally, the game might be neither winning, nor losing if the game graph has cycles., Let $N_a$ be a game of nim consisting of the only heap of size $a$. Then the game of nim on heaps, Let's prove that $N_{a_v}+G_v$, where $G_v = (V, \delta, v)$ is, indeed, a losinggame., Now, having a bit more of intuition on the product of nim game, we may define a product of, The game continues on until all cells with $x, y \geq 1$ have only coins facing tails up., The game continues on until there is no stone with positive coordinates left., The result above allows to [classify all game states on arbitrary graphs](https://cp-algorithms.com, Which is nice, but we'd also like to see some game theoretic implications of the nimber product, _Informally_, $G_1 + G_2$ is a game in which players have both $G_1$ and $G_2$ on the table, and in, }$, we end up with the game $N_{a_v} + N_{a_u}$, where $a_u \neq a_v$, hence the second player may match

Full text and comments »

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

48.
By neal, 5 years ago, In English
Weak system tests on today's Round 518 problem D: Computer Game For today's Div 1 problem D, [problem:1067D], once you succeed at a quest, it's clear you should upgrade and play the quest that maximizes your expected reward $p_i \times b_i$ for the remainder of the game. However, before you succeed at a quest, you have a difficult tradeoff to make: should you take a quest with a high probability of succeeding, to maximize your chances of upgrading and gaining optimal points for the rest of the game? Or should you take a quest that gives you more expected reward $p_i \times a_i$ right now? It turns out the answer to this tradeoff depends on $T$, the number of seconds left. As $T$ gets smaller, we should switch to quests with lower $p_i$ but higher immediate reward $p_i \times a_i$. This is because the long-term value of upgrading and maximizing future rewards becomes less relevant compared to getting more reward now. In particular, the optimal quest to pick (when we have not yet succeeded at any) can change multiple times as $T$ gets smaller a...
Weak system tests on today's Round 518 problem D: Computer Game, points for the rest of the game? Or should you take a quest that gives you more expected reward, the game.

Full text and comments »

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

49.
By SecondThread, history, 4 years ago, In English
LGMSniper.com: See which LGMs you have beaten! LGM Sniper ================== I just created a cool CF tool called [LGM Sniper](https://wumbogames.com/CompetitiveProgramming/LGMSniper). It looks at scoreboard data from every Div1 and Div1+Div2 round ever and tells you which LGM's you have beaten, how many times you have beaten them, and which rounds you beat them in. You can also compare yourself to your friends to see which one of you wins more! If you want to compare yourself with some friends, check the 'show ex-lgms' box and enter the friend you want to compare to as Handle #2, and they will show up on the bottom. You can try it out for yourself at [lgmsniper.com](https://wumbogames.com/CompetitiveProgramming/LGMSniper), or in the competative programming section of [Wumbo Games](https://wumbogames.com/), if you would prefer. Tooltips show the name of the rounds you won in (hover your mouse over the checkmark). If you find any interesting facts or have suggestions for how I could improve the tool, let me know in the co...

Full text and comments »

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

50.
By MikeMirzayanov, history, 9 years ago, translation, In English
How to come up with the solutions: techniques As I work with students I often face the situation when if a problem doesn't seem clear to a student at the first sight, it makes them unable to solve it. Indeed, you always hear about specific methods and techniques. But you don't hear about how to think in order to apply them. In this note I'll try to sum up my experience of solving programming contest problems. However, some pieces of advice will also be applicable for olympiads in mathematics and your first steps in academic research. So you've read a problem and you don't know how to solve it. Try the following techniques, some of them can often come handy. ##### Technique 1: "Total Recall" Try to remember some similar problems that you had to solve. Quite many problems do not have a brand new idea. So probably, you can use your experience of solving a similar problem to solve this one. ##### Technique 2: "From Specific to General" Let's say that you've found the solution for the problem (hurray!). Let's consider ...
on your own. If the problem is about a game, play it. Sometimes I try to visualize a process or a

Full text and comments »

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

51.
By DrSwad, history, 5 years ago, In English
A Beautiful Technique for Some XOR Related Problems ## Inspiration I'm very excited about this blog, as it took me quite a lot of effort and scavenging through the internet to completely grasp the concept of this technique(That's probably because I have almost zero knowledge in Linear Algebra or I'm just plain dumb). So I feel like I genuinely conquered a challenge, and I really want to share it with someone. But there's no way my CP friends circle will believe it, they'll think I'm just trying to show off :P So here I am, sharing it on CF. I also created a [personal blog](https://drschwad.github.io/), so that if I ever feel like sharing something again(not only about CP), I can write a blog there. I also added this same post [there](https://drschwad.github.io/2019-08-06-z2-space-xor-trick/), you can read it there if you prefer dark theme. I'll be pleased to hear any thoughts on the blog or if I can improve it in some way ^\_^ ## Introduction Since it concerns Linear Algebra, there needs to be a lot of formal stuff going on ...

Full text and comments »

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

52.
By Shafaet, history, 8 years ago, In English
Intro to Staircase Nim + Editorial for HackerRank "Move the Coins" Let's learn about Staircase Nim by solving [move the coins](https://www.hackerrank.com/contests/world-codesprint-april/challenges/move-the-coins) problem that appeared in HackerRank April World Codesprint. Among the problems I have ever created, its one of my favorites. If you don't want to solve that problem but want to learn about staircase-nim, just read the first part of this blog. Let's start with some backgrounds. **Staircase Nim** This problem is a variation of Staircase Nim problem, which is a not-very-well-known variation of classic Nim problem. If you don't know what Nim Game is, I suggest you first to learn about it. In Staircase Nim, there is a staircase with n steps, indexed from $0$ to $n-1$. In each step, there are zero or more coins. See the figure below: ![ ](http://codeforces.com/predownloaded/7e/ac/7eac2c9b216bbf89e52a5477854c81ec2dbdaf0c.png) Two players play in turns. In his/her move a player can choose a step $i>0$ and move one or more coins to s...
**A Game Theory Contest**, There will be a [multi-day Game Theory Contest](https://www.hackerrank.com/contests/5-days-of-game

Full text and comments »

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

53.
By Errichto, 5 years ago, In English
Sums and Expected Value — part 2 ### Instruction I recommend this blog also for red users. Read the theory and problems below, try to solve them. For solutions and extra insight/tips, watch my stream on Monday or watch the video later. If you aren't familiar with EV or summing problems, see part 1 first: [http://codeforces.com/blog/entry/62690] (http://codeforces.com/blog/entry/62690). I will stream a lecture on Monday at [14:00 CEST](https://www.timeanddate.com/worldclock/fixedtime.html?msg=EV+lecture+2&iso=20181029T14&p1=262) &mdash; [https://www.youtube.com/watch?v=HDk6zQw0Rdo](https://www.youtube.com/watch?v=HDk6zQw0Rdo) (also [Twitch](https://www.twitch.tv/errichto)). I will go through theory and problems from this blog. ### Expected Value theory, part 2 We roll a 6-sided die. Remember, EV of square of the number of pips is something different than square of EV: $$E(X^2) = \frac{1+4+9+16+25+36}{6} = 15.166666\ldots$$ $$E(X)^2 = (\frac{1+2+3+4+5+6}{6})^2 = 3.5^2 = 12.25$$ Two events are ...
will go through theory and problems from this blog., ### Expected Value theory, part 2, I recommend this blog also for red users. Read the theory and problems below, try to solve them

Full text and comments »

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

54.
By galen_colin, 7 weeks ago, In English
fix problem ratings pls (the rainboy effect) [The first few paragraphs of this blog, above the first spoiler, are just for story purposes and are irrelevant to the problem statement] One fateful day, a naive and young version of me from about 5 days ago had a dream. A dream to stop being so terrified of hard problems. A dream to conquer the most challenging stuff that CF ever had to offer. A dream to... ok, enough of that, that's so stupid. Basically, I've been grinding 3500s lately, mostly for fun (and my god, has it been fun). Two days prior, I found myself solving [1919G](https://codeforces.com/contest/1919/problem/G). That went fine, but after getting it, I noticed that despite G being 3500, it wasn't even the hardest problem in the contest &mdash; that honor went to the next problem, [1919H](https://codeforces.com/contest/1919/problem/H) (the subject of this blog), which had **no solves in-contest**. I concluded that I would have to be insane to try that, and moved on to other problems. Well, yesterday, I decided I...
that's it, game is broken, never using this site again

Full text and comments »

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

55.
By Geothermal, history, 4 years ago, In English
AtCoder Beginner Contest 169 Unofficial Editorial I just did my first ABC in a while, so I decided to write up and share my solutions below. Feel free to leave questions in the comments! There were several questions this round that had the potential to create precision issues; however, the solutions below give approaches that sidestep those errors altogether. Sadly, I think compiling and testing my A prevented me from winning the round :( #A &mdash; Multiplication 1 Just multiply the numbers and print them out. It's not that hard. Time Complexity: $O(1)$. [Click here for my submission.](https://atcoder.jp/contests/abc169/submissions/13800320) --- #B &mdash; Multiplication 2 This turns out not to be quite as easy as the last problem. Multiplying numbers this large is actually a challenge in C++ because the result is likely to be greater than $2^{63}$, and thus will cause long long overflow. Thus, in C++, we can't just multiply the numbers and check if the result is greater than $10^{18}$. One possible appr...
#D — Div Game

Full text and comments »

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

56.
By -is-this-fft-, history, 21 month(s) ago, In English
[Tutorial] Minimum cost (maximum) flow [Part 1: [Tutorial] My way of understanding Dinitz's ("Dinic's") algorithm](104960) **Part 2: [Tutorial] Minimum cost (maximum) flow** [Part 3: [Tutorial] More about minimum cost flows: potentials and Dinitz](105658) #### Introduction There is a section in our ICPC notebook from 2019 called "min cost dinic". This blog started as an attempt to dissect what was written in there and understand why it works. In time, I needed to refer to many general ideas about flow, so it developed into a more general treatment of (min-cost) flow problems and spawned an entire separate blog about maximum flow and Dinitz. Even after splitting the blog, this blog was still too long, so I split it yet again. This blog will deal with the basic ideas of minimum cost flow; there will be a part 3, where I will generalize to a Dinitz-like algorithm and also talk a bit about something called potentials. This blog is somewhat more technical and formal than I would ideally write, but there i...
importantly, in the theory of min-cost flow, negative cycles are not some pathological case that we, #### Basic theory of minimum cost flows, First, we must start by adapting the important concepts of maximum flow theory to the case of edge

Full text and comments »

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

57.
By -is-this-fft-, 2 years ago, In English
[Tutorial] Proving the inverse Ackermann complexity of Union-Find #### Introduction Most of us are familiar with the union-find data structure and the two optimizations one can do on it: _union by rank_ and _path compression_. Most tutorials will introduce these methods and state that if both optimizations are used, the complexity will be $\mathcal{O}((n + m) \alpha(n))$. Here, $n$ and $m$ are the number of vertices and queries respectively. What is $\alpha$? Generally, we are told that $\alpha$ is some mysterious function that grows very slowly: $\alpha(N) < 5$ where $N$ is the number of subsets of particles in the observable universe and whatnot. What it is is usually not clarified very much. And there is typically no proof (or intuition and other such justifications) as to why the complexity is like that: usually we're told that the complexity analysis is quite long and complicated. At the time of writing, both [cp-algorithms](https://cp-algorithms.com/data_structures/disjoint_set_union.html) and [Wikipedia](https://bit.ly/3EvnzrI) are like th...
theory $\alpha$ is an entirely different kind of beast. So if you're interested in thetheory, you

Full text and comments »

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

58.
By nor, 16 months ago, In English
[Tutorial] Greedoids: a formal way to look at families of greedily-solvable problems _Disclaimer: This is not an introduction to greedy algorithms. Rather, it is only a way to formalize and internalize certain patterns that crop up while solving problems that can be solved using a greedy algorithm._ **Note for beginners:** If you're uncomfortable with proving the correctness of greedy algorithms, I would refer you to [this tutorial](https://web.stanford.edu/class/archive/cs/cs161/cs161.1138/handouts/120%20Guide%20to%20Greedy%20Algorithms.pdf) that describes two common ways of proving correctness &mdash; "greedy stays ahead" and "exchange arguments". For examples of such arguments, I would recommend trying to prove the correctness of standard greedy algorithms (such as choosing events to maximize number of non-overlapping events, Kruskal's algorithm, binary representation of an integer) using these methods, and using your favourite search engine to look up more examples. Have you ever wondered why greedy algorithms sometimes magically seem to work? Or find them un...
important game (in fact, it has so many deep implications on combinatorics, that it is an important research, linear algebra and graph theory, and greedoids were a generalization of them when people realized that, Matroids have a much vaster theory compared to greedoids, due to being studied for quite a long

Full text and comments »

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

59.
By PrinceOfPersia, 9 years ago, In English
Algorithm Gym :: Graph Algorithms Welcome to the new episode of [user:PrinceOfPersia,2015-01-31] presents: Fun with algorithms ;) You can find all the definitions here in the book "Introduction to graph theory", Douglas.B West. [cut] Important graph algorithms : DFS --- The most useful graph algorithms are search algorithms. DFS (Depth First Search) is one of them. While running DFS, we assign colors to the vertices (initially white). Algorithm itself is really simple : ~~~~~ dfs (v): color[v] = gray for u in adj[v]: if color[u] == white then dfs(u) color[v] = black ~~~~~ Black color here is not used, but you can use it sometimes. Time complexity : $O(n + m)$. #### DFS tree DFS tree is a rooted tree that is built like this : ~~~~~ let T be a new tree dfs (v): color[v] = gray for u in adj[v]: if color[u] == white then dfs(u) and par[u] = v (in T) ...
path (read Introduction to graph theory)., You can find all the definitions here in the book "Introduction to graph theory ", Douglas.B West.

Full text and comments »

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

60.
By viktork, 10 years ago, translation, In English
ZeptoLab Code Rush 2014 <img src="http://assets.codeforces.com/images/zepto2014/image06.png" style="width:190px;float:right;margin:0 1em 1em 1em;"/> A coder can apply his breathtaking coding skills not only in different search engines but also in the mobile game industry. It is an option in Russia. If you do not believe &mdash; check this out: ZeptoLab company that created the world famous Cut the Rope game offers you the opportunity to see this for yourself. And yes, we are in Moscow. It's not a secret that those who strive to achieve top coding skills &mdash; work hard, including work on his self-education. Here in ZeptoLab we aim to create the area that strongly encourages self-development. Specifically, we have recently purchased a company library with everything necessary to get new knowledge, an improvised reading room with sofas and armchairs. <center> <img src="http://assets.codeforces.com/images/zepto2014/image08.jpg" style="width:400px;"/> </center> We also conduct developer's contest ...
the mobile game industry. It is an option in Russia. If you do not believe — check this out, : ideally, the application should output 60 frames per second on the target gadget. Allgame logic

Full text and comments »

Announcement of Zepto Code Rush 2014
  • Vote: I like it
  • +726
  • Vote: I do not like it

61.
By xyz2606, 3 years ago, In English
Contest 2050 and Codeforces Round #718 (Div.1 + Div.2) Hello Codeforces! [contest:1517] will take place on [contest_time:1517]. It's rated for everyone! The score distribution is **500--1250--1500--1750--2500--3000--3000--4000**. You will have 2 hours and 45 minutes to solve 8 problems. Contest 2050 is initiated by volunteers of the 2050 Conference. You can find out what is 2050 at the end of this blog. The contest is prepared by - [user:Fulisike,2021-04-21], [user:littlelittlehorse,2021-04-21], [user:Retired_MiFaFaOvO,2021-04-21], [user:xyz2606,2021-04-21] and we'd like to thank - [user:KAN,2021-04-23], [user:Nebuchadnezzar,2021-04-21] for their excellent coordination. - [user:absi2011,2021-04-21], [user:chitanda,2021-04-21], [user:Gromah,2021-04-21], [user:Itst,2021-04-21], [user:_cherry_,2021-04-21], [user:Aaeria,2021-04-21], [user:HIS_GRACE,2021-04-21], [user:A.K.E.E.,2021-04-21], [user:namanbansal013,2021-04-21], [user:Miracle03,2021-04-22], [user:yaoR,2021-04-23], [user:sshwyR,2021-04-23], [user:chenjb,2021-04-23]...
At 2050, we call it containers. There are 10 containers: 2050 Youth; Migratory Bird Program;Game

Full text and comments »

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

62.
By TheScrasse, history, 2 years ago, In English
[Tutorial] Diameter of a tree and its applications Hello everyone,<br> finding the diameter is one of the most frequent ways to solve problems about trees. In this tutorial we will see how to find a diameter and some of its properties, and we will use them to solve some problems of increasing difficulty.<br> The first part of the tutorial is quite basic, so feel free to skip it and jump to the problems if you already know the concepts. Target: rating $[1400, 2300]$ on CF<br> Prerequisites: basic graph theory, greedy The diameter ------------------ Given an unweighted tree, let's define $\text{dist}(a, b) =$ the number of edges in the simple path $a \rightarrow b$. A diameter of the tree $a \rightarrow b$ is the longest path, i.e., the one that maximizes $\text{dist}(a, b)$ over all pairs of nodes. If there are multiple diameters, let's pick any of them. The same definition is valid for a weighted tree with nonnegative weights (with $\text{dist}(a, b) =$ the sum of the weights of the edges in the simple path $a \rightar...
Target: rating $[1400, 2300]$ on CF Prerequisites: basic graph theory, greedy

Full text and comments »

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

63.
By TheScrasse, history, 3 years ago, In English
[Tutorial] Number theory — Storing information about multiples/divisors Hello everyone,<br> here is a very simple idea that can be useful for (cp) number theory problems, especially those concerning multiples, divisors, $\text{GCD}$ and $\text{LCM}$. Prerequisites: basic knowledge of number theory (divisibility, $\text{GCD}$ and $\text{LCM}$ properties, prime sieve). Idea ------------------ Let's start from a simple problem. _You are given $n$ pairs of positive integers $(a_i, b_i)$. Let $m$ be the maximum $a_i$. For each $k$, let $f(k)$ be the sum of the $b_i$ such that $k | a_i$. Output all pairs $(k, f(k))$ such that $f(k) > 0$._ An obvious preprocessing is to calculate, for each $k$, the sum of the $b_i$ such that $a_i = k$ (let's denote it as $g(k)$). Then, there are at least $3$ solutions to the problem. #### Solution 1: $O(m\log m)$ For each $k$, $f(k) = \sum_{i=1}^{\lfloor m/k \rfloor} g(ik)$. The complexity is $O\left(m\left(\frac{1}{1} + \frac{1}{2} + \dots + \frac{1}{m}\right)\right) = O(m\log m)$. #### Solution 2: $O(n\sq...
[Tutorial] Number theory — Storing information about multiples/divisors, Hello everyone, here is a very simple idea that can be useful for (cp) number theory problems, Prerequisites: basic knowledge of number theory (divisibility, $\text{GCD}$ and $\text{LCM

Full text and comments »

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

64.
By jqdai0815, history, 5 years ago, In English
A problem collection (Spoiler Alert) SPOILER ALERT : If you didn't solve the problems in NEERC and you want to enjoy the problems, please don't read. <spoiler summary="Spoiler"> It looks there are few problems about general graph matching in the community. And there are a few teams who solved problem B in NEERC both online and onsite. However, the reduction from maximum cost perfection matching to this problem is simple to me. So I want to share some problems for practice. You can find the template [here](http://uoj.ac/problem/81/statistics) and [here](http://uoj.ac/problem/79/statistics). The [shortest code](http://uoj.ac/submission/282287) of the maximum cost matching problem is about 5.7k. There is a simple way to find the cardinality of the maximum matching, which is half of the rank of the Tutte matrix. We can use Gaussian elimination to compute the rank of a matrix. By the way, if the maximum cost is no more than $W$, we can also find the maximum cost matching by Tutte matrix and polynomial interp...
8. Undirected Vertex Geography. Alice and Bob are playing a game on an undirected graph. They move

Full text and comments »

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

65.
By Konijntje, history, 6 years ago, In English
Why there are no syllabus in ACM-ICPC? I participated ACM-ICPC World Finals in 2017 and 2018, and I am trying to coach people who are willing to compete ACM-ICPC. As a participant and educator, I always wondered that "Why there are no syllabus in ACM-ICPC?" IOI has their syllabus. It changes from year to year, but it is least guideline that how can you ready for the competition. For example, 'non-trivial calculations on floating point numbers, manipluating precision errors' is excluded in IOI, so I did not practiced about real precision error deeply (but did in ACM-ICPC, since some problem requires it). Actually handling real numbers in computer is complicated, same recursion formula can earn different result, etc,. You can think about following problem: "Determine whether $\sqrt{a}+\sqrt{b} \ge \sqrt{c} + \sqrt{d}$ for integer $a$, $b$, $c$, $d$." Double precision cannot help you when each number is 5 digit. Which area you should concentrate on practicing ACM-ICPC or other programming contests? Even well-known part i...
, Computation Geometry, Graph Theory is for Master's degree.) and some is not covered by even graduate

Full text and comments »

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

66.
By E869120, 5 years ago, In English
My winning theory in IOI 2018 & 2019 — Why I won 2 golds in IOI Dear Codeforces community.<br /> According to [IOI 2019 Results](http://stats.ioinformatics.org/results/2019), I got the 25th place and got successful gold medals twice in a row.<br /> Although it was pretty close to the gold-medal border (only 6.14pts / 600 difference) and it was lower performance than IOI 2018, which I participated when I was orange in Codeforces, I had many chances to get more points in this IOI, even for top 10. Since there are not so many people who have got two gold medals in IOI (and there were many requests like "I want [user:E869120,2019-08-14] to talk about how to get gold in IOI" like [this comment](https://codeforces.com/blog/entry/66909?#comment-510127) and [this comment](https://codeforces.com/blog/entry/66909?#comment-513129)). I want to write something about IOI, which may be useful for people who will participate in IOI next year and also some years later.<br /> ![ ](https://i.ibb.co/TLmqRRX/E869120-IOI-01.png)<br /> <br /> ### A. First of all At...
My winning theory in IOI 2018 & 2019 — Why I won 2 golds in IOI

Full text and comments »

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

67.
By Geothermal, history, 9 months ago, In English
A Highly Experimental Training Plan for Beginners Very loosely inspired by some comments on [Thoughts on Reaching Cyan?](https://codeforces.com/blog/entry/101561) and [my recent AMA](https://codeforces.com/blog/entry/118845). Until now, I've avoided telling beginners to practice math before working on competitive programing problems because I haven't figured out a helpful way of doing so. This post is my attempt at telling grays to train math first in a way that might lead to improvement without an absurd time commitment. ## Introduction This section is largely motivation for why I'm proposing this training plan. If you just want to see the instructions for the training plan I'm proposing, you can skip this part. The first subsection in particular is not especially relevant to the rest of the post, but I wanted to have some documentation explaining why I still think the traditional "just solve problems" advice is good. ### The Conventional Advice on Improvement I'm frequently asked for advice on how to improve at co...
beginners than training directly on programming contest problems. To my knowledge, thistheory has not, concurrently with the next step. 3. **Number Theory:** Master all topics in NumberTheory. These topics, , combinatorics, and number theory problems numbered 1-5 on the AIME. Once you can solve these

Full text and comments »

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

68.
By MladenP, history, 2 years ago, In English
Best of COCI #2 Since the second round of this season of COCI (Croatian Open Competition in Informatics) was held [last saturday](https://codeforces.com/blog/entry/96881), here is the continuation in the series of COCI appreciation posts (I will post one after each COCI round, so six in total!). For my coaching, I went through all COCI contests since 2006 to gather tasks and selected some of my favorite ones. ### Notes - Check out the [first post](https://codeforces.com/blog/entry/96205) for notes about the process and the problemset. - There are 9 tasks in this problemset since I accidentally forgot to put one task (Zoo) last time, so it's included now. ### Tasks #### [A: 2016/2017, Contest 5: Ronald](https://evaluator.hsin.hr/tasks/HONI161756ronald/) Author: Adrian Satja Kurdija ([user:satja,2021-11-18]) Tags: <spoiler summary="Spoiler"> graph </spoiler> Note: <spoiler summary="Spoiler"> graph task without any graph algorithms </spoiler> Difficulty range: 1300-1500...
bipartite matching, game theory , simple task to practice bipartite matching, but showing a known game

Full text and comments »

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

69.
By adamant, history, 15 months ago, In English
Permutation group basis construction (Schreier–Sims algorithm) Hi everyone! I had this blog drafter for quite a while, but the [$300 contest](https://codeforces.com/blog/entry/110840) motivated me to actually finish and publish it. I don't care about the prize that much as I think many other blogs published recently are talking about something even cooler. But I like to make people suffer, so I will apply anyway to make [user:peltorator,2023-01-12] read even more stuff >:) Besides, the contest makes it harder to stay on contribution top, so I got to do something to stay afloat. That being said... <hr> Today I'd like to write about an algorithm that solves the following problem: You're given a set of permutations $G = \\{g_1, \dots, g_m\\}$. Find the size $|\langle g_1, \dots, g_m \rangle|$ of the group generated by $G$. At first, I wanted to get into a lot of group-theoretic details with proofs and all, but then I felt like it would make the article harder to comprehend, so I will try to keep group-theoretic stuff to minimum, whi...
Familiarity with basic group theory (e.g. definitions) will also be beneficial., In group theory terms, the last condition means that the set of permutations $G_1 \cup \dots \cup

Full text and comments »

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

70.
By purplesyringa, 3 years ago, In English
This is not an exit. ![This is not an exit.](https://i.ibb.co/N9zrDNp/cf.png) I am looking at the post called [*Is Mike Mirzayanov dictator?*](https://codeforces.com/blog/entry/94033) at the moment. I'm reading through the comments, I'm looking at people's reactions, I'm reading Mike's replies, and... I am utterly disappointed. I demand progress. For context, I do believe Codeforces is the best website for competitive programming contests at the moment. I sincerely give credit to Mike for creating Codeforces and providing participants and contest authors a platform for interaction completely for free. I am confident that Codeforces is the most appropriate website for being *the* platform for sharing knowledge, exchanging tricks and methods, and collaboration between both contest participants, their authors, and coordinators. **Please consider this an open letter**, for this is a will not of a single person, but of many individuals. Please consider signing it by stating so in a comment under the...
Then again, only to confirm the theory of low-hanging fruit. Users are now alerted when commenting

Full text and comments »

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

71.
By zscoder, history, 20 months ago, In English
[Contest] Statement Not Found: Season 2 #### Do you think you can solve CP problems without reading the problem statements? Let's find out! On [August 28, 2022 (Sunday) 19:30-22:00 GMT+8](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Statement+Not+Found+-+Season+2&iso=20220828T1930&p1=122&ah=2&am=30), I will hold an unofficial fun contest called Statement Not Found. As you can deduce from the title, there will be no problem statements (except title and samples). Your goal is to collect as many points as possible within 2.5 hours :) Obviously, this round is **unrated**. It is somewhere between April Fools contest and a legitimate contest. The contest will be OI-style, meaning there will be no time penalty. You are allowed to use any resources online to help solve the problems. There will be **12** problems. **Scoring Distribution:** 200-400-700-700-700-800-800-900-1100-1100-1100-1500 (Total: 10000) **Please read all problems** as problem difficulty is very subjective and a 1100-point problem might b...
You are playing a two-player game on a $n$ by $n$ grid where

Full text and comments »

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

72.
By ninja_28, history, 3 years ago, In English
CodeCraft-21 and Codeforces Round #711 (Div. 2) Editorial [problem:1498A] ================== #### [**Video Editorial**](https://www.youtube.com/watch?v=lV5cb8wh3sE) **Author and Problemsetting:** [user:ninja_28,2021-03-29] **Editorialist:** [user:sigma_g,2021-03-29] <spoiler summary="Hint"> Can you think of the simplest properties that relate a number and its sum of digits? </spoiler> <spoiler summary="Hint 2"> Note that if $X$ is a multiple of 3, then **both** $X$ as well as the sum of digits of $X$ are a multiple of 3! Can you put this property to use here? </spoiler> <spoiler summary="Hint 3"> If $X$ is a multiple of 3, then $\texttt{gcd-sum}(X) \ge 3$. Therefore, we are guaranteed that at least every third number will satisfy the constraints required by our problem $(\texttt{gcd-sum}(X) > 1)$. </spoiler> <spoiler summary="Solution"> Therefore, for the input $n$, we can simply check which one of $n$, $n+1$, and $n+2$ has its gcd-sum $> 1$, and print the lowest of them. </spoiler> <spoi...

Full text and comments »

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

73.
By adamant, history, 2 years ago, In English
On linear recurrences and the math behind them Hi everyone! There are already dozens of blogs on linear recurrences, why not make another one? In this article, my main goal is to highlight the possible approaches to solving linear recurrence relations, their applications and implications. I will try to derive the results with different approaches independently from each other, but will also highlight similarities between them after they're derived. ### Definitions **Def. 1**. An order $d$ **homogeneous linear recurrence with constant coefficients** (or _linear recurrence_) is an equation of the form $$ F_n = \sum\limits_{k=1}^d a_k F_{n-k}. $$ **Def. 2**. In the equation above, the coefficients $a_1, \dots, a_d \in R$ are called the **recurrence parameters**, **Def. 3**. and a sequence $F_0, F_1, \dots \in R$ is called an order $d$ **linear recurrence sequence**. <hr> The most common task with linear recurrences is, given initial coefficients $F_0, F_1, \dots, F_{d-1}$, to find the value of $F_n$. <hr> **Example...
). Formal theory behind it is as follows.

Full text and comments »

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

74.
By ko_osaga, history, 9 days ago, In English
Anarchy in the APSP: Algorithm and Hardness for Incorrect Implementation of Floyd-Warshall Hello Codeforces! I just uploaded the [first paper of my life](https://arxiv.org/abs/2404.08173) to arXiv, and I'm happy to share this with the community, especially because it is very related to competitive programming. Here is the [presentation](https://docs.google.com/presentation/d/1OE9cPSLMl4cHFqxjbPL8FRXo4ZKmRvTHKqgJbcoRobU/edit?usp=sharing) I gave in MIT Theory Lunch. ## What's the problem? Everyone knows the Floyd-Warshall algorithm for computing the shortest path, it goes like this: ~~~~~ rep(k, n) rep(i, n) rep(j, n) A[i][j] = min(A[i][j], A[i][k] + A[k][j]); ~~~~~ And everyone knows this *incorrect variant* of Floyd-Warshall. I certainly implemented this when I was learning CP, cause I kinda wanted to "fix the loop order". ~~~~~ rep(i, n) rep(j, n) rep(k, n) A[i][j] = min(A[i][j], A[i][k] + A[k][j]); ~~~~~ This is bad, it does not compute the shortest path. It does, however, compute "something". Imagine someone gives you a sparse graph and asks you to ...
/1OE9cPSLMl4cHFqxjbPL8FRXo4ZKmRvTHKqgJbcoRobU/edit?usp=sharing) I gave in MIT Theory Lunch.

Full text and comments »

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

75.
By zscoder, history, 3 years ago, In English
April Fools Day Contest 2021 — ZS Edition Hi everyone, April Fools is near and as usual we have an [April Fools Day Contest](https://codeforces.com/blog/entry/88840) on Codeforces this year. In addition to that, I usually try to host some form of mini April Fools Contest for my friends every year (or almost every year). This year, I am trying to host a bigger April Fools Day contest than usual and I invite everyone to participate! In view of the April Fools contest on Codeforces, the round will begin at [31 March 10pm (GMT+8)](https://www.timeanddate.com/worldclock/fixedtime.html?msg=April+Fools+Day+Contest+2021+%28ZS%29&iso=20210331T22&p1=122) and lasts for exactly $24$ hours (and thus it will end ~35 minutes before the CF April Fools round). The contest will consist of several unusual tasks, and I hope that everyone will at least find something interesting. The problems will not be sorted by increasing order of difficulty (if the word difficulty is even applicable), so it is **highly advisable** to read (and try!)...
Korone Game: 6, Untitled Subaru Game: 2 (madlads [user:AMO5,2021-04-01] and [user:Ari,2021-04-01]), game Pacman.

Full text and comments »

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

76.
By Geothermal, history, 4 years ago, In English
Gauging Interest in Training Program Hi all! I'm currently considering opening up a competitive programming training program of some sort. The details are definitely still in the works, though, and I wanted to discuss some preliminary ideas with the community to get feedback on what would be most helpful (and on whether there would be any interest in this). I'm interested in starting a training program for three main reasons: - To make competitive programming more accessible to those without access to resources like college courses or training camps - To provide a space in which questions are encouraged and actively answered (especially since I think this generally isn't the case in the community at large) - To help competitive programmers build problem-solving skills and intuition, which I think aren't sufficiently emphasized by most contest training resources I think one of the most frustrating things about being a new (or even intermediate) competitive programmer is that it's generally pretty difficu...
The target audience for this would depend on who's interested--I think that at least intheory, I'd

Full text and comments »

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

77.
By Noble_Mushtak, history, 15 months ago, In English
Every Technique and Algorithm I Used to Become Grandmaster Hi everyone, I became grandmaster today so I decided to go down memory lane and review every problem I have ever done in a CodeForces contest to look back and see every technique and algorithm I had to use to become a grandmaster. I am not sure how useful this is, I mostly think it's fun to look at all the old solutions I wrote and how different it was from how I write code now. The main takeaway is that, as many people have said before, you don't need to know or memorize a bunch of advanced algorithms to become grandmaster. As you will see, there are many problems where I just used "ad hoc reasoning," meaning there's not a standard technique I used to solve the problem and you just need to make some clever mathematical observations to solve the problem. Also, there are many popular algorithms that I have never needed in a CodeForces contest despite being a grandmaster: - Sparse tables, Fenwick trees, and segment trees - String algos, like rolling hashes, Knuth-Morris-Pratt, suffix...
): Game theory

Full text and comments »

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

78.
By I_love_Constructive, history, 9 months ago, In English
Common Impartial Combinatorial Games Theory Techniques in Competitive Programming In competitive programming, several types of combinatorial game theory questions are frequently encountered. These problems often involve strategies to win the game based on mathematical observations and proofs. In this blog, we'll discuss four common types of combinatorial game theory questions and their solutions. **1. Invariance** **2. Symmetry** **3. Reduction to Nim Game problems** **4. Solving using Dynamic Programming** In invariance and symmetric problems, certain properties of the game remain unchanged throughout its course. Although some may require mathematical proof, others can be solved through careful observations. **- Whytoff's Game:** The game involves two piles of stones with x and y stones, respectively. Two players, P1 and P2, take turns choosing a pile and removing at least one stone from it. The player who cannot make any move loses. Let's remove the 'a' stone from both piles such that a >= min(x, y). Whoever can't make any move will lose. **Solutio...
Common Impartial Combinatorial Games Theory Techniques in Competitive Programming, **Game Theory is a Math-Based Topic!**, -days-of-game-theory/challenges), In competitive programming, several types of combinatorial game theory questions are frequently

Full text and comments »

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

79.
By Tima, history, 17 months ago, In English
ICPC WF 2021 Prediction Game Good luck and have fun to all finalists! I suggest to us(the fans) to play the following game: **Rules of the game:** Choose your top 12 teams, this will be your prediction for the ICPC final. For each team you choose, you can get points. The conditions are as follows: - if the team gets a medal, then you earn +2 points - if the team gets the medal you predicted, then you earn +1 point. In your prediction, we will assume that the first 4 teams get gold medals, the next 4 teams get silver medals and the last 4 teams &mdash; bronze medals. - if the team gets the predicted place, then you earn +2 point. Thus, one team can bring up to 5 points. The points of your prediction are the sum of the points of the 12 teams you have chosen. If you want to participate in the game, you can submit your prediction [here](https://codeforces.com/contestInvitation/771115929227f4dcf45bca9788327f7ab6462d3f). Also, you can check your prediction [here](https://codeforces.com/conte...
ICPC WF 2021 Prediction Game, **Rules of the game:**, Good luck and have fun to all finalists! I suggest to us(the fans) to play the followinggame, I suggest to us(the fans) to play the following game:, If you want to participate in the game, you can submit your prediction [here](https, Thanks to all participants of prediction game!

Full text and comments »

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

80.
By mango_lassi, history, 5 years ago, In English
Problem H (Game on the Tree) from CCPC 2018 [This problem](https://codeforces.com/gym/102055/problem/H) I have a solution I think is correct but can't get it to pass, and apparently even my n^2 code (standard game theory iterating through all states solution) that should obviously work gets WA. They both give the same answers for random small inputs. I can't find editorials or test data for the contest, so seeing so many teams have +1 or more in this problem, is there some tricky corner case I might have missed? My code if it is of any interest: <spoiler summary="code"> ~~~~~ #include <iostream> #include <vector> #include <utility> #include <algorithm> using namespace std; const int INF = (int)1e9 + 7; bool findCycle(int i, vector<int>& cycle, vector<int>& par, const vector<vector<int>>& conns) { for (auto t : conns[i]) { if (par[i] == t) continue; if (par[t] != -1) { if (par[t] == i) swap(t, i); while(i != t) { cycle.push_back(i); i = par[i]; } cycle.push_back(i); re...
Problem H (Game on the Tree) from CCPC 2018, (standard game theory iterating through all states solution) that should obviously work gets WA. They

Full text and comments »

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

81.
By Elegia, history, 2 months ago, In English
How to composite (some) polynomials faster? Hi everyone, today I'd like to elaborate something more on the [problem I](https://codeforces.com/contest/1930/problem/I) on the recently ended div 1 contest. As described in the [official solution](https://codeforces.com/blog/satyam343), a bottleneck of the problem is the following: Given a sequence $\{c_j\}_{-n \leq j \leq n}$, compute $$ g_k = \sum_{-k\leq j\leq k} ([x^j] (x + 1/x)^k) c_j $$ for all $0 \leq k \leq n$. In the official solution, an $O(n\log^2 n)$ time algorithm is presented, and we also claimed that it is possible to compute $g_k$ in $O(n\log n)$ time. In this post, I'd like to elaborate on how to do that. By the way, another bottleneck of the problem is the relaxed convolution problem, where the usual implementation also takes $O(n\log^2 n)$ time. I mentioned in [comment](https://codeforces.com/blog/entry/111399#comment-996712) that the relaxed convolution has a somehow practical solution that has time complexity $$ O\left(\frac{n\log^2 n}{\log \log n...
that can be represented by the composition chain. This seems to let me recall the Galoistheory, or, The game ends with the following trick: $$ (x^3 - 3x) \circ \frac{x+x^{-1}}{2} = \frac{x^3+x^{-3, You might suspect that there is some magic theory behind this, but actually I don't have. The only

Full text and comments »

Discussion of think-cell Round 1
  • Vote: I like it
  • +269
  • Vote: I do not like it

82.
By gojira, 2 years ago, In English
A look at Competitive Programming post-hibernation Hello friends! As I've recollected in a previous [post](https://codeforces.com/blog/entry/97566), I am an old competitor who hadn't really participated since ~2014, and recently got a bout of nostalgia to return to Competitive Programming. So, I did a couple Topcoder SRMs, suffered through some SNWS rounds, participated in [three regional 5hr competitions](https://contest.yandex.ru/3QF2021) on three consecutive days, and dozed off at every Codeforces contest I tried to wake up for. A lot of things are still the same as 8 years ago: [user:tourist,2022-01-26] is still at the top, grey coders still ask for how many minutes to solve a problem before reading the editorial, Russian university teams [continue winning](https://icpc.global/worldfinals/results) ACM ICPC, and Snarknews never gives up on his alternate competition formats. But in this post, I want to focus on the new patterns that emerged since my last time around. #### #1: Codeforces rounds timing Did you know that t...
Most probability theory-related problems I've seen in the past months request the answer modulo

Full text and comments »

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

83.
By zscoder, history, 8 years ago, In English
Codeforces Round #372 Editorial We hope everyone enjoyed the problems. Here is the editorial for the problems. I tried to make it more detailed but there might be some parts that might not be explained clearly. [Div. 2 A &mdash; Crazy Computer](http://codeforces.com/contest/716/problem/A) ------------------ Prerequisites : None This is a straightforward implementation problem. Iterate through the times in order, keeping track of when is the last time a word is typed, keeping a counter for the number of words appearing on the screen. Increment the counter by $1$ whenever you process a new time. Whenever the difference between the time for two consecutive words is greater than $c$, reset the counter to $0$. After that, increment it by $1$. Time Complexity : $O(n)$, since the times are already sorted. <spoiler summary="Code (O(n))"> ~~~~~ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #def...
Prerequisites : Math, Graph Theory, DP, Any fast multiplication algorithm

Full text and comments »

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

84.
By MikeMirzayanov, history, 8 years ago, translation, In English
Open Codeforces Rating System [updated on October 2015] Starting from October 2015 ratings formulas are open. They are given in the post. It is likely that from time to time we will change them slightly, it will be reflected here. The basic idea of Codeforces rating system is to generalize Elo rating to support games with multiple participants. Each community member is characterized by value $r_i$ &mdash; integer number. Roughly speaking, the higher value means better results in the contests. Rating is calculated/recalculated so that the equality strives to be correct: $$P_{i,j}=\frac{1}{1+10^{\frac{r_j-r_i}{400}}},$$ where $P_{i,j}$ is probability that the $i$-th participant has better result than the $j$-th participant. Therefore for two participants the probability to win/lose depends on subtraction of their ratings. For example, if the difference of ratings is equal to 200 then stronger participant will win with probability ~0.75. If the difference of ratings is equal to 400 then stronger participant will win with probabi...

Full text and comments »

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

85.
By sirknightingfail, history, 5 years ago, In English
A blog on the Sprague-Grundy Theorem So, I ended up making a talk on Sprague-Grundy as part of a club at my school, and thought that the denizens of codeforces would appreciate it. As follows is roughly what was on the handout, which goes over Sprague-Grundy along with the application of its theory to Nim. As this is my first blog post on Codeforces, please do let me know if there are any mistakes in formatting. I hope you find this interesting, as writing and explaining this helped me understand how to apply it to problems. This handout was written as more math-oriented, so it may be a bit heavy. The exercises are left unsolved, as they are intended to be worked through by the reader. If you just want to get to what the Sprague-Grundy is defined as, search for "The Sprague-Grundy function of a game" after reading how games were defined. Way too much theory ============================= A necessary definition of games ------------------------------- For this talk, a game will be a two-player sequential game o...
Way too much theory ============================= A necessary definition of games

Full text and comments »

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

86.
By MikeMirzayanov, 7 years ago, translation, In English
Playrix Codescapes Cup <img src="http://assets.codeforces.com/users/kguseva/playrix2017/11.png" style="width:500px;float:right;padding: 0 1em 1em 1em;"/> Hello, Codeforces! I'd like to invite you to join in Playrix Codescapes Cup <b>for the both divisions</b> that will be held on <a href="http://timeanddate.com/worldclock/fixedtime.html?day=11&month=5&year=2017&hour=18&min=35&sec=0&p1=166">May 11 at 18:35 MSK</a>. The round is <b>rated</b> and open for everyone. Problems are prepared by [user:KAN,2017-05-10], [user:Al.Cash,2017-05-10], [user:MikeMirzayanov,2017-05-10] and [user:fcspartakm,2017-05-10]. Huge thanks to [Playrix company](https://www.playrix.com/) for making this round possible. Hope you enjoy the round! ![ ](http://assets.codeforces.com/users/kguseva/playrix2017/33.png) [Playrix](https://www.playrix.com/) is one of the leading mobile games development companies in the world. Its distributed team consists of 450 professionals from around the world. The company has released three s...
release.In 2016, Facebook named Gardenscapes game of the year.

Full text and comments »

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

87.
By DeadlyCritic, history, 4 years ago, In English
Codeforces Round #652 (Div. 2) Editorial ####[A. FashionabLee :](https://codeforces.com/contest/1369/problem/A) Invented by [user:DeadlyCritic,2020-06-16]. <spoiler summary="Brief Solution"> $\mathcal Brief\;\mathcal Solution :$ A $n$-regular convex polygon is beautiful if and only if $n \% 4 = 0$. ($\%$ is the modular arithmetic symbol) </spoiler> <spoiler summary="Complete Proof"> [tutorial:1369A] </spoiler> <spoiler summary="Python solution"> ~~~~~ t = int(input()) for testcase in range(t): n = int(input()) if(n%4 == 0) : print("Yes") else : print("No") ~~~~~ </spoiler> <spoiler summary="C++ solution"> ~~~~~ #include <iostream> using namespace std; int main(){ int t; cin >> t; while(t--){ int n; cin >> n; if(n % 4 == 0){ cout << "YES\n"; } else cout << "NO\n"; } } ~~~~~ </spoiler> ####[B. AccurateLee :](https://codeforces.com/contest/1369/problem/B) Invente...
Define $win_{s,\,e}$ ($s \le e$) equal to $1$ if Lee can win the game when $s$ is written on the

Full text and comments »

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

88.
By errorgorn, 3 years ago, In English
Codeforces Global Round 13 Editorial [problem:1491A] ------------------ Setter: [user:syksykCCC,2021-02-28] Prepared by: [user:syksykCCC,2021-02-28] <spoiler summary="Hint 1"> How can we find the largest $k$ such that the $k$-th smallest element of the array is $0$? </spoiler> <spoiler summary="Hint 2"> How can we maintain $k$? </spoiler> <spoiler summary="Solution"> Let's define $cnt$ to represent the number of 1s in the array. For the modifications, if $a_i$ is already $1$ now, then we let $cnt \gets cnt - 1$. Otherwise, let $cnt \gets cnt + 1$. For the querys, just compare $cnt$ with $k$. If $cnt \ge k$, the answer will be $1$. Otherwise, the answer will be $0$. The complexity : $O(n + q)$. </spoiler> <spoiler summary="Code (C++)"> ```c++ #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int n, q, a[N], cnt; int main() { scanf("%d%d",&n,&q); for(int i = 1; i <= n; ++i) { scanf("%d",a+i); cnt += a[i]; } while(q--) { int opt, x; ...
How to find when a RED is destroyed or when the game ends event, anything but the game ends //we need to handle that case carefully! //i think lets just insert it, manually, check if the game ends. Then we recompute the color of all animals, and repeat. If no event, right before the two REDs should be able to win, and hence the game should end within $2n$ moves, when the game ends. , ){ ///GREEN type event occured, game ends ans = min(ans, ii(totalMoves + R.pos + 2, belt[i].id)); } }, , and it loses to next animal, then it is BLUE. If it wins one more time (and hence the entiregame) it, game ends. This occurs when $B_{g} > A_{r}$ where $g$ is any GREEN, if(arr[0].a > arr[1].a) swap(arr[0],arr[1]); ///settle first game arr.push_back(arr[0

Full text and comments »

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

89.
By gKseni, 7 years ago, translation, In English
Code Festival 2016: interview and photos from participants [Code Festival 2016](http://codeforces.com/blog/entry/48616) was held in Tokyo on 25-30 of November. Boris [user:qwerty787788,2016-12-13] Minaev has shared with us his impressions, and Maxim [user:Zlobober,2016-12-13] Ahmedov and Nicolay [user:KAN,2016-12-13] Kalinin shared photos. &mdash; _To start with, let's mention that,_ [AtCoder](https://atcoder.jp/) _and_ [Indeed company](http://ru.indeed.com/about) _announced the festival. How many quals were there? In what way were they arranged?_ &mdash; There were 3 contests, in which you could take part. In the first part TOP-10 were selected, in the second one — TOP-5, the third one — TOP-5. To sum up, there are 20 foreigners to be selected. &mdash; _Which quals the Japanese had then?_ &mdash; Probably the same, but 200 participants passed the qual there. &mdash; _That means, the event is more orientated on Japanese people?_ &mdash; The previous years the event was held only for Japanese, this year they decided ...

Full text and comments »

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

90.
By Radewoosh, 9 years ago, In English
Codeforces Round #304 (Div.2) editorial A. Soldier and Bananas ---------------------- We can easily calculate the sum of money that we need to buy all the bananas that we want, let's name it x. If n >  = x the answer is 0, because we don't need to borrow anything. Otherwise the answer is x - n. B. Soldier and Badges --------------------- Let's count the number of badges with coolness factor 1, 2 and so on. Then, let's look at the number of badges with value equal to 1. If it's greater than 1, we have to increase a value of every of them except for one. Then, we look at number of badges with value 2, 3 and so on up to 2n - 2 (because maximum value of badge which we can achieve is 2n - 1). It is easy to see that this is the correct solution. We can implement it in O(n), but solutions that work in complexity O(n^2) also passed. C. Soldier and Cards -------------------- It's easy to count who wins and after how many "fights", but it's harder to say, that game won't end. How to do it? Firstly le...
D. Soldier and Number Game --------------------------, It's easy to count who wins and after how many "fights", but it's harder to say, thatgame won't, So war has (n + 1)! states. If we'd do (n + 1)! "fights" and we have not finished thegame yes

Full text and comments »

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

91.
By errorgorn, 2 years ago, In English
On Div2ABs 2 years ago, [user:antontrygubO_o,2022-04-27] wrote [a blog](https://codeforces.com/blog/entry/75163) about div2ABs where he expressed his opinions that d2ABs should not be about "here is a statement, please implement what is written there". Thanks to him, the quality of d2ABs (and problem quality in general) have certainly improved. However, I still believe that there still quite large differences between how coordinators/problemsetters view d2ABs and how the intended participants view them. From the survey made by [user:kpw29,2022-04-27], we can see that most people agree that most people agree that we should **primarily** consider the target audience when proposing a task. I too think if a task is boring to div 1 contestants, we should not think of that as a reason to immediately disqualify a problem from being a d2A. ![ ](https://codeforces.com/predownloaded/70/b5/70b515da85a4dc3b362cf4eb0963dbd1fb642819.png) I think when people judge the interesting-ness of d2As, they try...
feels like a "guess and check" game where they cannot prove anything they submit and just hope that, - [problem:1266A] — requires quite a bit of requisite knowledge on number theory which is, theory, combinatorics) which only math major or minors/math olympiad people may be acquainted with well

Full text and comments »

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

92.
By adamant, history, 21 month(s) ago, In English
Duality in linear programming. Part 1 — definition and construction Hi everyone! Previously I [wrote](https://codeforces.com/blog/entry/98334) about theoretical grounds of "aliens trick". Specifically, I introduced the concept of the Lagrangian duality and explained its connection with the trick. Today I want to elaborate a bit more on the concept of dual problems and their applications to linear programming as well as to common problems in competitive programming. I initially wanted to also write about some applications in competitive programming problems, but given that the introduction is already quite lengthy, I decided to leave it for another blog, while using most common and well-known theoretical examples here, focusing more on how to construct and interpret dual problems to begin with, rather than how to use it in contests. I think, it is a crucial first step towards using the duality in actual programming challenges. #### Prerequisites It is highly recommended to have some general understanding of basic mathematical optimization...
\in X} [f(x) - \lambda^\top g(x)]$. From this fact follows the following theory :

Full text and comments »

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

93.
By nor, 2 years ago, In English
[Tutorial] Generalized Möbius Inversion on Posets This blog will be more about developing ideas about certain structures rather than actually coding up stuff. The ideas we'll be developing here have many applications, some of which involve: - Number Theoretic Möbius Inversion - Principle of Inclusion-Exclusion - Directed Acylic Graphs - Subset Sum Convolution - Finite Difference Calculus (and prefix sums) Note that some of the terminology used below might be non-standard. Also, some parts of the blog make a reference to abstract algebra without much explanation; such parts are just for people who know some algebra, and can safely be skipped by those who don't know those concepts at all. Prerequisites: - Some knowledge about graphs. - Matrix multiplication - Basic combinatorics ## Definition of a poset and some intuition All of these have one thing in common: they have an underlying "poset". Let's understand what a poset is. Rigorously speaking, a poset is a partially ordered set, i.e., a set $S$ equipped wit...
there's a lot more to the theory we have developed above than just this formula. However, we shall

Full text and comments »

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

94.
By adamant, history, 12 months ago, In English
Pythagorean triples and Pell's equations Hi everyone! Recently I started solving projecteuler, and while doing so I encountered two concepts about which I heard before, but I didn't really bother to learn them. I made a few notes to myself about how they work, and thought it could be useful for somebody else too. This blog focuses on Pythagorean triples and Pell's equations, which are recurrent concepts on projecteuler. Great thanks to [user:nor,2023-05-07], [user:Endagorion,2023-05-07], [user:Golovanov399,2023-05-07] and [user:Neodym,2023-05-07] for useful discussions about these topics. [cut]<hr> #### Pythagorean triples **Pythagorean triple** is a triple $a,b,c \in \mathbb Z$ such that $$ a^2 + b^2 = c^2. $$ It is possible to parameterize them in a way that allows to find all triples such that $a,b,c \leq n$ in $O(\sqrt n)$. ##### Rational points on a unit circle To do that, let's divide the equation by $c^2$ to get $$ \left(\frac{a}{c}\right)^2 + \left(\frac{b}{c}\right)^2=1. $$ This re...
The term near $y_k$ is known to be $(-1)^k$ from the theory of continued fractions, thus

Full text and comments »

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

95.
By awoo, history, 9 years ago, translation, In English
Creating Gravity Defied tracks using Codeforces rating graph Introduction ============ <img src="http://cs624422.vk.me/v624422694/36ac0/8jKq7pMzPOc.jpg" style="float: right;"></img> Hi everybody! Recently I have decided to refresh memories about good old times and play Gravity Defied on my phone. It wasn't really hard to find port of that legendary game from J2ME to modern platforms. It rapidly gained glory among students of past decade. Key points of Gravity Defied success were nice gameplay (biker completing different stages with high cliffs and deep pits), convinient physics (ability to rotate mid-air) and simplicity of modmaking. As for me, it was a bit more than usual game. When I had completed over thousand tracks, I began earning money on helping others to progress. Only later even more difficult games were developed: HOMM 3, Far Cry and Dark Souls... Predevel story ============ <img src="http://cs624422.vk.me/v624422694/370dd/wU1hi77t6U8.jpg" style="float: right;"></img> And now Gravity Defied is on my phone again! Not o...
Defied on my phone. It wasn't really hard to find port of that legendary game from J2ME to modern, . I can totally declare that atmosphere of game was transferred great! And one more time I got

Full text and comments »

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

96.
By mfv, history, 8 years ago, In English
Experimental Educational Round: VolBIT Formulas Blitz Hello, Codeforces! “Experimental Educational Round: VolBIT Formulas Blitz” will take place on [February <b>18</b>, 2016 at <b>18</b>:00 MSK](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Experimental+Education+Round%3A+VolBIT+Formulas+Blitz&iso=20160218T15). This time the problemset is recommended for Div.2 participants. The round will be unrated for all users and it will be held according to the standard ACM-ICPC rules. You will have **180** minutes (three hours) to solve **18** problems. There will be no open hacks phase after the round. Our main target audience is beginners and Div. 2 members. All offered problems can be solved without conditional constructs and without loops. Only formulas are required. Assignments and functions can be used to reduce code duplication. The topics of the problems are: - combinatorics - geometry - game theory - sequences - other The round is created as a part of [Vologda BIT event](https://vk.com/volbit35), also as pa...
- combinatorics - geometry - game theory - sequences - other

Full text and comments »

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

97.
By purplesyringa, history, 2 years ago, In English
Analysis of polynomial hashing Unfortunately, most derivations of the chance of polynomial hashing collision are invalid, wrong, or misleading, and finding reliable public sources with proofs is incredibly difficult. This article is a formal analysis of the method. The goal of this article is to complement well-known empirical facts with theory, provide boundaries on the probability of collision, justify common choices, and advise against certain popular parameters. There is no code in this article, and it's mostly theoretical. It's more of a summa of everything we know about polynomial hashing in integers rather than a guide for beginners. You'll probably find something of interest still. I do, however, describe some methods of cracking hashes, which I can provide code and additional explanation for if someone asks in the comments and some general guidelines in the last section of the present article. ## Table of contents - The concept of polynomial hashing - Classical justification of the coprimality r...
. This, in theory, somewhat reduces the probability of collision, but not much.

Full text and comments »

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

98.
By dacin21, history, 6 years ago, In English
On the mathematics behind rolling hashes and anti-hash tests This blog assumes the reader is familiar with the basic concept of rolling hashes. There are some math-heavy parts, but one can get most of the ideas without understanding every detail. The main focus of this blog is on how to choose the rolling-hash parameters to avoid getting hacked and on how to hack codes with poorly chosen parameters. # Designing hard-to-hack rolling hashes ## Recap on rolling hashes and collisions Recall that a rolling hash has two parameters $(p, a)$ where $p$ is the modulo and $0 \leq a < p$ the base. (We'll see that $p$ should be a big prime and $a$ larger than the size $\left|\Sigma\right|$ of the alphabet.) The hash value of a string $S = s_0 \dots s_{n-1}$ is given by $$ h(S) := \left(\sum\limits_{i=0}^{n-1} a^{n-1-i} s_i\right) \mod p $$ For now, lets consider the simple problem of: given two strings $S, T$ of equal length, decide whether they're equal by comparing their hash values $h(S), h(T)$. Our algorithm declares $S$ and $T$ t...
().time_since_epoch()).count(); ~~~~~ Either of the two should be fine. (In theory

Full text and comments »

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

99.
By Errichto, 9 months ago, In English
Group tutoring Hi. I offer classes for groups of 2-3 students. I teach competitive programming with a focus on problem-solving. There won't be many lectures because I can send you an article/video link instead. The lesson cycle is usually: I choose a problem, you say your thoughts and ideas, I comment on incorrect ideas, and we talk about the valid solution(s), possibly with drawings and pseudocode. In beginner groups, I might ask you to implement something, C++ or Python preferred. There's a lot of homework and you're expected to practice a few hours per week. We might spend half a lesson talking about 1-2 homework problems from last week. This is intended. We use Google Meet, shared whiteboard, and a collaborative editor Codebunk. After a lesson, you get a video recording and a codebunk with code/text history like this one https://codebunk.com/pb/3501100331621/. This allows you to copy links and code easily. There's a Discord group chat to ask questions between classes. - 1.5h les...

Full text and comments »

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

100.
By dmkz, 6 years ago, translation, In English
"The bug" — old brutal russian game for programmers On the Internet since 2004 there is a game ["Bug"](http://buglab.ru). This is in russian, but you can use the google translator for translate all page, or ask me if there is something that is not clear after translation. **Goal of game** &mdash; build a correct labyrinth 19 x 29 for bug. Result &mdash; number of bug's movements from start point to finish point. The results on the site are sorted by the amount of movement of the bug for the passage of the labyrinth. Algorithm of bug's movement: >>Bug always starts movement from the upper left corner, and the exit is always in the lower right corner. The bug is not moving optimally, but in the following way: he goes to where he was not yet, or was there less often. Passing every cell of the labyrinth, the beetle remembers: how many times he was in this cell and when thinking about the direction of his movement at some particular moment he looks: how many times he was in the cell from down side, how many from the right side, how man...
"The bug" — old brutal russian game for programmers, **Goal of game** — build a correct labyrinth 19 x 29 for bug. Result — number of bug's, On the Internet since 2004 there is a game ["Bug"](http://buglab.ru). This is in russian, but you, Those interested are invited to play the game "Bug", to generate labyrinths and research this

Full text and comments »

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

101.
By Abinash, 10 years ago, In English
Good Blog Post Resources about Algorithm and Data Structures There are many good blogs in **Codeforces Blog** where people describes about different **Algorithm and Data Structures** . Lets gather all the resources about **Algorithm and Data Structures** Explanations. You can comment bellow the link and about it . I will always update that post gather new resources.Hope ,its help all and inspire all to write new blog post in future :) Last added blogs link will have a tag **(New)** Resources: **C++ STL** [C++ STL: Policy based data structures]( /blog/entry/11080) [C++ STL: Policy based data structures. Part 2]( /blog/entry/13279) **String Processing** [Suffix tree. Basics. Building in O(nlogn)]( /blog/entry/11337) [Z Algorithm]( /blog/entry/3107) [Great resource for string algorithms]( /blog/entry/8008) [Aho-Corasick algorithm. Construction]( /blog/entry/14854) [Suffix tree. Ukkonen's algorithm](/blog/entry/16780) [On suffix automaton (and tree)](/blog/entry/22420) **New** **Data Structur...
**Game Theory**

Full text and comments »

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

102.
By adamant, history, 22 months ago, In English
Partitions and pentagonal number theorem Hi everyone! In today's blog I'd like to write about the theorem that allows to efficiently solve the following problems: - What is the number of partitions of a non-negative number $n$ for $n \leq 10^5$? - What is the number of partitions of a non-negative number $n$ for $n \leq 10^5$, so that no summand repeats $d$ or more times? - What is the number of partitions of a non-negative number $n$ for $n \leq 10^5$, so that no summand is divisible by $d$? - **[HackerEarth &mdash; Perfect Permutations](https://www.hackerearth.com/de/problem/algorithm/perfect-permutations-september-clash/)**: What is the number of permutations of length $n$ with $k$ inversions for $k \leq n \leq 10^5$? - **[problem:102354E]**: Let $\phi = \frac{9}{10} \cdot \frac{99}{100} \cdot \frac{999}{1000} \cdot \dots$, what is the $k$-th digit of $\phi$ for $k \leq 10^{18}$? - **[SNSS-2018 Round 5 &mdash; Investment Portfolio](https://contest.yandex.ru/contest/8703/problems/C/)**: You have $2n$ dollars and ...
notion of combinatorics. - Basic notion of number theory.

Full text and comments »

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

103.
By jqdai0815, 10 years ago, In English
Codeforces Round #268 Editorial I'll upload my example solutions and will post links to them as soon as it becomes possible. All the problems in Div 1 don't have the unique solution. I list several solutions to each problems. There are also some interesting bonus problems. I can't solve some of them yet :( If you have interesting ideas, feel free to share and discuss your ideas in the comments. :) My English is poor, so if there are some mistakes or something you can't understand, you can also discuss it in the comments. [problem:469A] [I Wanna Be the Guy](http://kayin.moe/iwbtg/downloads.php) is an interesting game. I strongly recommend it to you. The problem itself is easy. Just check if all the levels could be passed by Little X or Little Y. [submission:7894174] [problem:469B] This problem is not hard. Just iterator over all possible $t$, and check if the schedule of Little X and Little Z will overlap. [submission:7894252] **Bonus:** 1. $p,q\leq 50, l,r\leq 10^9$ 2. $p,q,l,r\leq 1...
[I Wanna Be the Guy](http://kayin.moe/iwbtg/downloads.php) is an interesting game. I strongly

Full text and comments »

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

104.
By emorgan, 3 years ago, In English
[Tutorial] Slight Generalization of Grundy Numbers **Prerequisites**: Grundy numbers (aka nimbers, I will refer to them as Grundy numbers), the connection of Grundy numbers to mex and bitwise xor. **Note about mex**: We know the the mex of a set of non-negative integers is the smallest non-negative integer which is not in the set. This definition works fine for any proper subset of $\mathbb{N}$, since $\text{mex}(S)=\min(\mathbb{N}\setminus S)$, and min is well-defined for any non-empty subset of $\mathbb{N}$. However, the minimum of an empty set is not well-defined, so neither is $\text{mex}(\mathbb{N})$, so we will define a new object $\omega=\text{mex}(\mathbb{N})$. Most of the properties of this object as it relates to mex are pretty straight-forward, for example <br><br> $$ \text{mex}(\mathbb{N}\cup\{\omega\}) = \omega+1 $$ $$ \text{mex}(\{a\omega+b\,|\,a,b\in\mathbb{N}\}) = \omega^2 $$ **Games with Finite States**: Given any finite impartial game (i.e. an impartial game which is guaranteed to terminate in a finite number o...
column, then it is equivalent to a game of nim, i.e., parallel such that each player first gets to choose a game on which to make a move, and then chooses any, the pile (possibly 0), (and as many normal nim moves as they wish). Then this game is equivalent to a, $$ g([a_n,...,a_1,a_0]) = \sum\limits_{i=0}^{n}a_i\omega^i $$ I'm not aware if this type ofgame, {N}\}) = \omega^2 $$ **Games with Finite States**: Given any finite impartial game (i.e. an

Full text and comments »

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

105.
By kpw29, 9 years ago, In English
1st Hunger Games Large Editorial — Community solutions This is the second part of Hunger Games Editorial, hope you'll enjoy it :) And again, thanks for stuff for awesome contest, congratz for survivors too! **UPD**: Problems B, D, E, Q, T, W are now available, more soon :) **Editorial Hall of Fame:** [user:Stonefeang,2015-08-26] [user:Andres_Unt,2015-08-26] [user:cuber2460,2015-08-26] [user:Anonym_KALEP,2015-08-26] [user:adamant,2015-08-26] [user:ngoisao_93,2015-08-27] [user:gendelpiekel,2015-08-27] [user:fcdkbear,2015-08-27] [user:izrak,2015-08-27] **Problem A: Good Numbers.** Tutorial by: [user:ngoisao_93,2015-08-28] Call `LCM(i, j)` the lowest common multiple of i and j. First, we should analyse that if x is divisible by `LCM(p^i, q^j)`, then x is divisible by `p^i` and `q^j` at the same time. Call set `s(i, j)` the set of number x in range [l, r] that x is divisible by `LCM(p^i, q^j)`. Call `|s(i, j)|` the size of s(i, j). We can find out that: `|s(i, j)| = |s(1, j)| - |s(1, i-1)| = r/LCM(p^i, q^j...

Full text and comments »

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

106.
By YouKn0wWho, 2 years ago, In English
A List of Useful Equations in Competitive Programming Hi, I am super excited to be back with another list. This time it is a **collection of some useful equations in Competitive Programming**. ### Motivation Do you find it bad if you couldn’t solve a problem just because you didn’t know about a certain equation? Do you find it difficult to take a quick look at an equation that you know exists but forgot about it while solving a problem? Do you think that all the equations that are important in CP are just cluttered and you are too lazy to collect them in one place? Well, then you are in the right place! I am here to solve all of the aforementioned problems. I believe you should not waste your precious time searching the internet for important equations. You should solve more problems. I am here to undertake the nasty task of collecting things. ### Payment Everything comes with a cost. You need to do something for me. That is you need to upvote this blog. Pretty easy! ### Acknowledgement Thanks to the following guys ...
stuff in Combinatorics, Number Theory, and Math but found it hard to keep track of the equations that

Full text and comments »

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

107.
By AlexLuchianov, 2 years ago, In English
Story about a certain interactive problem Some time ago, I was part of the scientific committee at [infO(1)Cup](https://info1cup.com/). While discussing problems with other members of the committee I proposed the following problem: _You have to play a game against the interactor on a $N$ by $M$ matrix. Initially all cells are unclaimed. You and the interactor, alternatively, take turns claiming a non-empty set of unclaimed cells. The set of cells chosen in a turn has to be able to fit in a $K$ by $K$ bounding box without being rotated and has to be connected. (There exists a path between any two cells in the set passing only through cells in the set, we define a path as a sequence of cells such that any two consecutive cells have a common side). You can choose whether to play first or second._ Before I discuss the solution to the above problem, I first wish to show you a similar puzzle known in the folklore as _"The round table coin game"_ or as _"The faustian round table coin game"_ . The puzzle goes as follows: ...
in the folklore as _"The round table coin game"_ or as _"The faustian round table coingame"_ . The, ###Open questions - Do we have a name for this type of game theory problems, where there exists an

Full text and comments »

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

108.
By dmkz, history, 12 months ago, In English
Invitation to Bug Game [marathon problem, mirror of buglab.ru] Hello Codeforces! **UPD.** [user:I_love_natalia,2023-04-18] crashed the checker by his maze with $10^9$ moves. The problem is resolved now and all of the solutions rejudged. Scoring is changed. [More info](https://codeforces.com/blog/entry/115144?#comment-1023668) **UPD 2:** The official site [https://buglab.ru/](https://buglab.ru/) was updated. See [comment](https://codeforces.com/blog/entry/115144?#comment-1024061). **UPD 3:** The checker has been speeded-up by [user:mfv,2023-05-01] in $2.2$ times (in comparison with my checker. The new speed is equal to $4$ seconds for a $10^9$ moves in codeforces "Custom Invocation"). Current standings: 1. $17\cdot 10^9$ &mdash; [user:sas4eka,2023-05-01]; 2. $14\cdot 10^9$ &mdash; [user:I_love_natalia,2023-05-01]; 3. $6.8 \cdot 10^9$ &mdash; [user:maxplus,2023-05-01] (on the buglab: $11.3 \cdot 10^9$). **UPD 4:** I updated the checker: now mazes up to $42$ billions are supported before checker got TL. Time limit of checker on codef...
Invitation to Bug Game [marathon problem, mirror of buglab.ru], **Official Russian site of Bug Game:** [click here](https://buglab.ru/), I'm happy to invite you to an unofficial mirror of [Bug Game ](http://buglab.ru/). In thisgame you

Full text and comments »

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

109.
By -is-this-fft-, history, 21 month(s) ago, In English
[Tutorial] More about minimum cost flows: potentials and Dinitz [Part 1: [Tutorial] My way of understanding Dinitz's ("Dinic's") algorithm](104960) [Part 2: [Tutorial] Minimum cost (maximum) flow](105330) **Part 3: [Tutorial] More about minimum cost flows: potentials and Dinitz** #### Introduction As mentioned in the introduction of [part 2](105330), there is something in out ICPC notebook called "min cost dinic". This cycle (no pun intended) of blogs was initially meant to be just one blog explaining it all, but in time it developed into something much longer. The general idea here doesn't appear to be particularly widely discussed, but it is certainly not novel either; [TopCoder](https://www.topcoder.com/thrive/articles/Minimum%20Cost%20Flow%20Part%20Two:%20Algorithms), for example, calls it the primal-dual algorithm (why is it called that? That's a story for another time, but it has to do with [LP duality](105049).) Picking up from where we left off, there are still two things to talk about: - Where does Dinitz come in? ...
The theory laid out in part 2 paves the way for proving the correctness of algorithm 2.

Full text and comments »

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

110.
By tallnut_liu, 2 months ago, In English
(Plenty of) useful blogs in CodeForces Here are some useful blogs I found in CodeForces. Note that: - This list can be treated as an extension of [catalog](https://codeforces.com/catalog), since much of these tutorials are included in catalog but the others are collected by myself. - The same blog may be included in this post twice or more. - Blogs to ask questions are **NOT** included in this blog, since they seemed not quite useful to CP. - If there are any blogs that I have missed, please tell me in the comment section. Thank you very much. Hint: you can use Ctrl+F to search for information here. # General Advices ## Micellaneous - [How to use Codeforces [GUIDE]](https://codeforces.com/blog/entry/99660) - [[Tutorial] The command line: how to read input from file without #ifdef and much more](https://codeforces.com/blog/entry/102287) - [After a Round FAQ](https://codeforces.com/blog/entry/103654) - [[Tutorial] How to read editorials](https://codeforces.com/blog/entry/123882) - [Pro Tips — get them whi...
## Game Theory - [Nim (Algorithmic Game )](https://codeforces.com/blog/entry/3657) - [The

Full text and comments »

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

111.
By ouuan, history, 4 years ago, In English
One thing you should know about comparators — Strict Weak Ordering Is "In C++, comparator should return false if its arguments are equal." [all you should know about comparators in C++](https://codeforces.com/blog/entry/70237)? **Definitely NOT.** ### What's the requirement of the custom comparator in STL? It should be a *Strict Weak Ordering*. In other words, let the comparator be $f$, and $f(x, y)=true$ means $x< y$, then: 1. $f(x, x)$ must be false (Irreflexivity) 2. If $f(x, y)$ is true, then $f(y, x)$ must be false. (Antisymmetry) 3. If $f(x, y)=true$ and $f(y, z)=true$, then $f(x, z)$ must be true. (Transitivity) 4. If $f(x, y)=false$, $f(y, x)=false$, $f(y, z)=false$ and $f(z, y)=false$, then $f(x, z)=false$ and $f(z, x)=false$. (Transitivity of equivalence) In fact, *Antisymmetry* can be deduced by *Irreflexivity* and *Transitivity*, so we can ignore it. Here are some examples that these rules aren't satisfied: | Comparator | Irreflexivity | Transitivity | Transitivity of equivalence | Example | | :----------: | ...
theory, there may be mistakes. Please make a comment if you find any mistakes.

Full text and comments »

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

112.
By Zlobober, 8 years ago, translation, In English
Codeforces Round #376 (Div. 2) editorial I'm sorry for a delay with publishing the editorial. [problem:731A] -------------- Problem author: [user:egor-belikov,2016-10-17], developer: [user:timgaripov,2016-10-17] In this problem you have to implement exactly what is written in the statement, i. e. you should find minimum number of rotations from letter `a` to the first letter in the input, then to the second one and so on. The only useful knowledge that may simplify the solution is that the distance between points $x$ and $y$ on the circle of length $l$ (26 in our case) is $\min(|x - y|, l - |x - y|)$. This solution works in $O(|s|)$, and, of course, fits in time limit. [problem:731B] -------------- Problem author: olympiad jury, developer: [user:platypus179,2016-10-17] In a correct answer we may guarantee that for any two consecutive days we use no more than one coupon for bying pizzas in these days. Indeed, if we have two coupons for buying pizzas in days $i$ and $i + 1$, replace these coupons for two ...
First of all, comment on such type of games. In CS the game where two players are willing to

Full text and comments »

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

113.
By Corvus, history, 6 years ago, In English
[Training] [Arabic] ACM JCPC Summer Training 2018 Hello Codeforces, From 27/8/2018 to 6/9/2018 the JCPC Summer Training 2018 was held, two weeks covers varied topics consists of 4 different levels 1 &mdash; 4 and Level 1 and 2 consists of 5 lectures and Level 3 and 4 consists of 4 Lectures. The training is recorded and published on youtube on [user:SolverToBe,2018-09-02] channel *note: language of training is Arabic. **Level 1** ----------- **Lecture 1** &mdash; Presented By Mohammad Zuhair [user:Zuhair,2018-09-02] <spoiler summary="STL Data Structures"> Part 1 | [Vector](https://www.youtube.com/watch?v=svZA0aRRYvg) Part 2 | [Pair](https://www.youtube.com/watch?v=8W_lryPTj-s) Part 3 | [Complexity](https://www.youtube.com/watch?v=ZBrzms-78iQ) Part 4 | [Queue](https://www.youtube.com/watch?v=dcr8SzMAdT4) Part 5 | [Stack](https://www.youtube.com/watch?v=ZTQiPSCDIqo) Part 6 | [Priority Queue](https://www.youtube.com/watch?v=ZDR4STKNkxQ) </spoiler> **Lecture 2** &mdash; Presented By Nada Al-Shamayleh [us...
Part 1 | [Nim Game](https://www.youtube.com/watch?v=gp2JrB92n1c)

Full text and comments »

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

114.
By TheScrasse, history, 16 months ago, In English
Competitive Programming Roadmap (target: [gray, blue]) tl;dr ------------------ - Competitive programming roadmap [here](https://drive.google.com/file/d/16Jydn250Ue7K7hOfzLxw4p5jFF4ZCqWT/view?usp=sharing). - It should be suitable both for newcomers and for people with some experience with CP: let's say, up to blue on Codeforces. - It contains ~ 100 "must-know" problems about various topics: ad-hoc, STL, binary search, DP, number theory, graphs. - There are solution sketches at the bottom, don't feel guilty reading them if stuck. Why? ------------------ Many people new to Codeforces seek advice about how to get better / which problems to try. Other people are stuck on gray / green even after solving a lot of problems. This roadmap aims to be a solution. My take: to be good at competitive programming, you have to know "what to think" and "how to think" when you try a problem. - "What to think": you have to know a decent amount of standard problems / techniques. Sometimes, a problem requires steps / observations that seem ob...
various topics: ad-hoc, STL, binary search, DP, number theory, graphs. - There are solution

Full text and comments »

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

115.
By AquaMoon, 8 months ago, In English
Harbour.Space Scholarship Contest 2023-2024 (Div. 1 + Div. 2) Editorial Thank you for participation and we hope you enjoy this round ヽ(^ o ^)/. During the contest, there was a small issue in problem D. For those affected, we have skipped your duplicate submissions (if your duplicate submissions were not skipped, please let us know). We apologize again for any inconvenience caused. In addition, we are honored to invite you to our unofficial round tomorrow (*╹▽╹*) [Invitation to TheForces Round #22 (Interesting-Forces)](https://mirror.codeforces.com/blog/entry/119771) ### [1864A-Increasing and Decreasing](https://mirror.codeforces.com/contest/1864/problem/A) Idea : [user:wuhudsm,2023-08-27] <spoiler summary="Tutorial"> We use the following greedy construction: For all $i$ ($1<i<n$), set $a_i=a_{i+1}-(n-i)$. If $a_2-a_1 \geq n-1$, we've found a solution, otherwise there is no solution. Proof. Assume there's a solution which includes an index $i$ ($1<i<n$) such that $a_{i+1}-a_i>n-i$. We can make $a_j:=a_j+\Delta$ for all $j$ ($2 \le j ...
First, let's analize a single game for fixed $a$, $b$, and how many, ### [1864E-Guess Game](https://mirror.codeforces.com/contest/1864/problem/E)

Full text and comments »

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

116.
By Monyura, history, 9 years ago, translation, In English
Looksery Cup 2015 Editorial **UPD** Editorial of problem E was added, I apologize for the delay. Hope you found it interesting. **A. Face Detection** Author: [user:Monyura,2015-06-06] One should iterate through each 2x2 square and check if it is possible to rearrange letters in such way they they form the word "face". It could be done i.e. by sorting all letters from the square in alphabetic order and comparing the result with the word "acef"(sorted letters of word "face"). **B. Looksery Party** Author: [user:Igor_Kudryashov,2015-06-06] In any cases there is such set of people that if they come on party and send messages to their contacts then each employee receives the number of messages that is different from what Igor pointed. Let's show how to build such set. There are 2 cases. There are no zeros among Igor's numbers. So if nobody comes on party then each employee receives 0 messages and, therefore, the desired set is empty. There is at least one zero. Suppose Igor thinks that i-th emp...
**C. The Game Of Parity**

Full text and comments »

Tutorial of Looksery Cup 2015
  • Vote: I like it
  • +246
  • Vote: I do not like it

117.
By adamant, history, 22 months ago, In English
Lagrange inversion theorem Hi everyone! There is a concept that is sometimes mentioned [here](https://codeforces.com/blog/entry/77284?#comment-622525) and [there](https://codeforces.com/blog/entry/77551). The [Lagrange inversion theorem](https://en.wikipedia.org/wiki/Lagrange_inversion_theorem). Let $x = f(y)$. We want to solve this equation for $y$. In other words, we want to find a function $g$ such that $y = g(x)$. The Lagrange inversion theorem gives an explicit formula for the coefficients of $g(x)$ as a formal power series over $\mathbb K$: $$ \large k[x^k] g(x) = [x^{-1}] f^{-k} $$ In a special case $y = x \phi(y)$, that is $f(y) = \frac{y}{\phi(y)}$, which is common in combinatorics, it can also be formulated as $$ \large k[x^k] g(x) = [x^{k-1}] \phi^k $$ Finally, to avoid division by $k$ one may use (see the [comment](https://codeforces.com/blog/entry/104184?#comment-925505) by [user:Elegia,2022-06-25]) the following formula: $$ \large [x^k]g(x) = [x^{-2}] f' f^{-(k+1)}, $...
(e.g. Taylor series); - Basic concepts of graph theory (graphs, trees, etc); - Basic concepts of

Full text and comments »

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

118.
By defnotmee, history, 16 months ago, In English
Brazilian Bizarre Adventures at the TST Hello codeforces! I was reminiscing about the brazilian TST that just happened and figured it was way too crazy not to share with everyone how it went. So as a follow up to [this blog](https://codeforces.com/blog/entry/109950) I'll be going through my experiences at the event. Get ready for a ride, because this is gonna be a long one. Day of Arrival: Coming out of the closet ------------------ The people of my school all gathered in a bus to go to the hotel we were staying at. That bus made a beeping noise every time we passed 90 km/h, and considering we were travelling at night, we were hearing that noise way too often! While in the ride, I stole [user:LFFB_,2022-12-11]'s laptop and started playing Osu on it. Even though I was playing on the touchpad and the bus was bumping around, I was able to clutch out an S on "Pepsi Man", which was quite a challenge despite being on relax mode. ![ ](https://media.discordapp.net/attachments/1049687529298866216/1051480070755201107/indi...
card game called Truco. My team won the last game and I was popping off when we received a message, Then we go to the same room as before to watch the game of Brazil vs Croatia. We were only able to, Yeah, we went to a different room so they could project the game for us. It was really cool.

Full text and comments »

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

119.
By awoo, history, 13 months ago, translation, In English
Educational Codeforces Round 145 [Rated for Div. 2] Hello Codeforces! On [contest_time:1809] [contest:1809] will start. Series of Educational Rounds continue being held as [Harbour.Space University](https://harbour.space/) initiative! You can read the details about the cooperation between [Harbour.Space University](https://harbour.space/) and Codeforces in the <a href="http://codeforces.com/blog/entry/51208">blog post</a>. This round will be **rated for the participants with rating lower than 2100**. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest, you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally. You will be given **6 or 7 problems** and **2 hours** to solve them. The problems were invented and prepared by Adilbek [user:adedalic,2023-03-19] Dalabaev, Ivan [user:BledDest,2023-03-19] Androsov, Maksim [user:Neon,2023-03-19] Mescheryakov ...
1. **Intermediate**: _Become a pro-grammarians by diving into the main concepts of web andgame

Full text and comments »

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

120.
By bmerry, history, 6 years ago, In English
Retiring from rated contests I've been thinking of retiring from algorithm contests for a while, having failed to qualify for any on-sites in 2017 or 2018 (I'm excluding DCJ from algorithm contests). This is definitely a young person's game and I can feel I'm not as sharp as I used to be. I still love problem solving, but when I'm under time pressure and just can't see the solution and know my rating is going to crash, I get so stressed and frustrated that I don't enjoy it any more. Now that both my Topcoder and Codeforces ratings are back over 3000 I've decided to retire from rated contests so that I'll go out on a high. I will most likely continue to do unrated contests where if I have a bad day I can just walk away instead of stressing myself out. I might also get more involved in testing contests.
person's game and I can feel I'm not as sharp as I used to be. I still love problem solving, but when

Full text and comments »

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

121.
By Atomic-Jellyfish, 7 months ago, In English
Codeforces Round 901 (Div. 1, Div. 2) Editorial ## [problem: 1875A] <spoiler summary="Tutorial"> We can use one tool each time the timer reaches to $1$, then the answer will be $\sum_{i=1}^n \min(a - 1, x_i) + b$. This can prove to be optimal. Because for each tool, if we use it when the timer is $c$, its contribution to the answer is $\min(x_i, a - c)$. We can't use the tool when the timer is less than or equal to $0$ because the bomb will explode before that, so $c=1$ is the optimal. Time complexity: $O(n)$ per test case. Memory complexity: $O(1)$ per test case. </spoiler> <spoiler summary="Code"> ```c++ #include<bits/stdc++.h> using namespace std; int n = 0, a = 0, b = 0; long long ans = 0; inline void solve(){ scanf("%d %d %d", &a, &b, &n); ans = b; for(int i = 0, x = 0 ; i < n ; i ++){ scanf("%d", &x); ans += min(a - 1, x); } printf("%lld\n", ans); } int T = 0; int main(){ scanf("%d", &T); for(int i = 0 ; i < T ; i ++) solve(); return 0; } ``` </spoiler> ## [probl...
### 1. The game after we get the flash card, ### 2. The game before we get the flash card

Full text and comments »

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

122.
By Nanako, 16 months ago, In English
Good Bye 2022 -- Editorial ## [problem:1770A] Idea by [user:m_99,2022-12-30] <spoiler summary="Hint 1"> Exactly $n$ items out of of $a_1,\ldots,a_n,b_1,\ldots,b_m$ will remain on the whiteboard at the end. </spoiler> <spoiler summary="Hint 2"> $b_m$ will always remain on the board at the end. </spoiler> <spoiler summary="Hint 3"> Consider the case where $n=2$ and $m=2$. As we mentioned in hint 2, $b_2$ will always be written, but what about $b_1$? </spoiler> </details> <spoiler summary="Solution"> This problem can be solved naturally with a greedy algorithm &mdash; for $i = 1, 2, \dots, m$, we use $b_i$ to replace the minimal value among the current $a_1, a_2, \dots, a_n$. The time complexity is $O(nm)$ for each test case. Alternatively, we can first add $b_m$ to our final sum. For the remaining $(n+m-1)$ integers, we can freely pick $(n - 1)$ out of them and add it to our final sum. This is because if we want a certain $a_i$ to remain on the board at the end, we simply do not touch i...
related to graph theory.

Full text and comments »

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

123.
By cip999, 3 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...

Full text and comments »

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

124.
By -is-this-fft-, history, 7 days ago, In English
[Tutorial] The residual graph and working with the set of all minimum cuts I have previously written about flows in these blogs: [1](https://codeforces.com/blog/entry/104960), [2](https://codeforces.com/blog/entry/105330), [3](https://codeforces.com/blog/entry/105658). Minimum cuts are a very fascinating topic for me. There are a lot of maximum flow problems where there's a fairly simple chain of reductions leading to "you should use flow", but there are also a lot of flow problems where flow comes apparently out of nowhere. Particularly fascinating are those where it's more convenient to think in terms of minimum cut: they work, because minimum cut allows you to model partitioning a set in two, with some additional implication-like constraints. Here are a couple of problems with that nature: - [ARC085E \- MUL](https://atcoder.jp/contests/arc085/tasks/arc085_c) (this reduction is almost standard these days) - [ARC142E \- Pairing Wizards](https://atcoder.jp/contests/arc142/tasks/arc142_e) - [problem:104925D] There are also flow problems on graphs ...
neatly into some discussion of more general and abstract theory.

Full text and comments »

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

125.
By vici, 14 years ago, In English
Game Theory 1 <p class="MsoNormal" style="text-indent: 21.0pt;"> <i>At first I must say that I have no gift in English, or Russian. So if you can’t catch my meaning, but what I can say is sorry. I promise I will try my best to improve my English. And I still have interest in Russian, for the reason that my dad is a great Russian speaker. Maybe I can communicate with you in Russian soon after.</i></p> <p class="MsoNormal" style="text-indent: 21.0pt;"> <span>Ok, let’s go! What I want to talk about is an interesting problem, Game Theory. Yes, I will connect Game Theory with ACM, and show you how to deal with these problems.</span></p> <p class="MsoNormal" style="text-indent: 21.0pt;"> <span>But what is Game Theory? I <span class="lijuyuanxing">quote the explanation in wiki. </span> &nbsp;</span></p> <p class="MsoNormal" style="text-indent: 21.0pt;"> <span class="apple-style-span"> <span style="font-size: 7.5pt;font-family: Arial , sans-serif;...
Game Theory 1, But what is Game Theory? I , is an interesting problem, Game Theory. Yes, I will connect Game Theory with ACM, and

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

126.
By adamant, history, 10 months ago, In English
Dirichlet convolution. Part 2: Dirichlet series and prime counting Hi everyone! Recently I've published a [blog](https://codeforces.com/blog/entry/117635) about how one can multiply and divide sequences with Dirichlet convolution. In this blog, we will learn about a convenient framework to reason about them in a "coordinate-free" notation, similar to how generating functions are used to analyze sequences under the regular convolution. - **[Part 1: Fast prefix sum computation](https://codeforces.com/blog/entry/117635)** - **Part 2: Dirichlet series and prime counting** We will learn how to deal with Dirichlet multiplication and division in the framework of Dirichlet series, and derive a number of well known number theoretic results from this perspective. While doing so, we will learn about Riemann zeta function and will have a glimpse into why it is so important in analyzing behavior of prime numbers. We will also learn how Dirichlet series framework helps us to, given $g(1), \dots, g(n)$, to compute $f(1), \dots, f(n)$ in $O(n \log n)$ s...
#### Multiplicative functions In number theory, first and most natural example of where Dirichlet

Full text and comments »

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

127.
By Arpa, history, 19 months ago, In English
Ten years of Competitive Programming Hey Codeforces! I’m AmirReza PourAkhavan, Codeforces Contest Coordinator. I let the story become complete and I’m sharing it now. The story is about a 16-year competitive programmer, who left his family and migrated to another city alone to follow competitive programming. After seven years, he advanced to the International Collegiate Programming Contest World Finals, twice. ### Why I’m writing this Six years ago someone asked me [here](https://codeforces.com/blog/entry/45186?#comment-297837) to write my story. I think it can help you to never give up. ### A brief about me I've been doing competitive programming for ten years. I advanced to ICPC (International Collegiate Programming Contests) World Finals twice, in 2019 at Porto and 2020 at Moscow. At ICPC World Finals 2020, our team took high-honored place twenty-four, which is equal to the top 0.03% of 200k students participating in ICPC. <center> <br> <img width="50%" src="/predownloaded/c2/0c/c20c501bba688...
simple graph theory problems. I started 10th grade with a rating of 1057, Newbie.

Full text and comments »

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

128.
By vovuh, history, 4 years ago, translation, In English
Codeforces Round #615 (Div. 3) &lt;almost-copy-pasted-part&gt; Hello! [contest:1294] will start at [contest_time:1294]. You will be offered 6 or 7 problems (or 8) with expected difficulties to compose an interesting competition for participants with ratings up to 1600. However, all of you who wish to take part and have rating 1600 or higher, can register for the round unofficially. The round will be hosted by rules of educational rounds (extended ACM-ICPC). Thus, during the round, solutions will be judged on preliminary tests, and after the round it will be a 12-hour phase of open hacks. I tried to make strong tests &mdash; just like you will be upset if many solutions fail after the contest is over. You will be given 6 or 7 (or 8) problems and 2 hours to solve them. Note that **the penalty** for the wrong submission in this round (and the following Div. 3 rounds) is **10 minutes**. [Remember] (/blog/entry/59228) that only the <i>trusted participants of the third division</i> will be included in the ...
_So unofficial participants are also in a game (if meet the requirements)._

Full text and comments »

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

129.
By orz, history, 16 months ago, In English
Northern Eurasia Finals 2022 has concluded Two days ago Northern Eurasia Finals 2022 [took place](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Northern+Eurasia+Finals+2022&iso=20221207T1015&p1=352&ah=5), mirror of which was on Codeforces: [contest:1773]. In the next few hours the [standings](http://nerc.itmo.ru/archive/2022/standings.html) got unfrozen, thereby we know the list of the teams that qualified to the ICPC Finals this year: **1<sup>st</sup> place &#127942;** [MIPT](https://codeforces.com/ratings/organization/38): Yolki-palki ([user:Pechalka,2022-12-09], [user:Kapt,2022-12-09], [user:Tikhon228,2022-12-09]) **2<sup>nd</sup> place &#129351;** [HSE](https://codeforces.com/ratings/organization/250): FFTilted ([user:Kirill22,2022-12-09], [user:teraqqq,2022-12-09], [user:Ormlis,2022-12-09]) **3<sup>rd</sup> place &#129351;** [SPb SU](https://codeforces.com/ratings/organization/16): Urgant Team ([user:sava-cska,2022-12-09], [user:74TrAkToR,2022-12-09], [user:orz,2022-12-09]) **4<sup>th</sup> place &#...
Whatever theory is true, I am kind of overjoyed to finally make it to the Finals and to have such a, ], are sticklers of the theory that this is rather a blessing than a curse, that with my qualification

Full text and comments »

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

130.
By adamant, history, 15 months ago, In English
Unlabeling combinatorial species (cycle index series) Hi everyone! In my [previous blog](https://codeforces.com/blog/entry/103979), I wrote about how generating functions can be used to enumerated labeled species. In this blog, I want to continue the topic by writing about how one can account for different kinds of symmetries when counting different combinatorial structures. Ultimately, we will end up deriving and hopefully understanding the analogue of [Pólya enumeration theorem](https://en.wikipedia.org/wiki/Pólya_enumeration_theorem) in species. Difficulty: ★★★★☆ Prerequisites: - Familiarity with combinatorial species (see my [prev. blog](https://codeforces.com/blog/entry/103979)), OR - Very good intuition with enumerative combinatorics, genfuncs and recap below. I will try to use plain language rather than formulas as much as possible, as it seems to be the preferred format for readers. ## Recap Below is a very brief recap of the most important things from the previous article. I tried to keep it as informal as p...
The theory of combinatorial species described in the previous blog post is based on an assumption

Full text and comments »

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

131.
By DeMen100ns, history, 21 month(s) ago, In English
Codeforces Round #812 (Div. 2) Editorial <spoiler summary="Before the round starts"> Great efforts have been put over last year. We want to say thanks to everybody who helped us to make this round as it is. Cannot wait to see you guys on the next one! <spoiler summary="Testers' predictions"> <table> <tr style ="background-color:#D3D3D3"> <th>Tester</th> <th>A</th> <th>B</th> <th>C</th> <th>D</th> <th>E</th> <th>F</th> </tr> <tr> <td>[user:tfg,2022-08-06]</td> <td>800</td> <td>1100</td> <td>1500</td> <td>1600</td> <td>1900</td> <td>2400</td> </tr> <tr> <td>[user:neko_nyaaaaaaaaaaaaaaaaa,2022-08-06]</td> <td>800</td> <td>1100</td> <td>1700</td> <td>1900</td> <td>2100</td> <td>2600</td> </tr> <tr> <td>[user:BucketPotato,2022-08-06]</td> <td>800</td> <td>1000</td> <td>1400</td> <td>1800</td> <td>2400</td> <td>-</td> </tr> <tr> <td>[user:LetterC67,2022-08-0...
- The $1^{st}$ participant wins more game than the $3^{rd}$ one: the $2^{nd}$ and $3^{rd}$ cannot, - The $3^{rd}$ participant wins more game than the $1^{st}$ one: the $1^{st}$ and $4^{th}$ cannot

Full text and comments »

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

132.
By WolfBlue, history, 2 years ago, In English
Seemingly hard problems trivialized by a single simple observation Here I've enumerated some of my favorite problems. The solutions appear trivial in retrospect &mdash; but the 1 line observation is quite hard to come up with. You have to think really outside of the box for these! I think such problems are quite cool and hard to come by, so please add a comment if you have any other problems of this type that you've seen! They are arranged from easiest to hardest (in my opinion). 1) For $N<10^6$, what's the Nth palindromic number in base 10 with an even number of digits? (The first is 11, then 22, 33, 44, 55, 66, 77, 88, 99, 1001). Key observation: <spoiler summary="Spoiler"> Just concatenate N with itself backwards. </spoiler> Source: https://codeforces.com/contest/688/problem/B 2) A classic: $N < 10^6$ Ants are on a line of length $10^{15}$ at some positions $p_i$. Each has a starting position and direction left or right. They walk at a rate of 1 unit per second, and if 2 collide, both immediately turn around and walk the other...
Source: A class in complexity theory

Full text and comments »

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

133.
By Xellos, 11 years ago, In English
Codeforces Trainings Season 1 Episode 4: Editorial ### A. Arrangement of RGB Balls (difficulty: easy) If, among 3 consecutive balls, there are no two of the same color, then there's exactly one ball of every color among them. Thereforce, the sequence is determined by the order of the first 3 balls. Imagine these are RGB; then, the sequence continues as RGBRGBRGB... There are only $3!=6$ possible initial triples, so we can try all the sequences defined by them, and for every one of them, check if it can be constructed. [cut] When is it possible to construct such a sequence? Take the initial triple to be "GRB", for example (the idea for other triples is analogous). It's clear that the sequence is "GRB" repeated some $K$ times, and after that, there are the first 0, 1 or 2 balls from that triple (for example, "GRBGRBGR" or just "G"). It's clear that $K=min(R,G,B)$. So it's possible to construct iff $1\ge G-K \ge R-K \ge B-K$. Testing the existence of any sequence can be done in $O(1)$ time like this. There are $O(1)$ possib...
Let's recall some terms from the game theory. A position is a state of the game , in this case

Full text and comments »

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

134.
By adamant, history, 13 months ago, In English
Oleksandr Kulkov Contest 3 in gym + tutorial and comments Hi everyone! As the [Universal Cup stage 7](https://codeforces.com/blog/entry/113640) which mirrored my contest from the [Osijek Competitive Programming Camp 2023](https://codeforces.com/blog/entry/113438) just concluded, I decided to also upload the contest to gym as [contest:104234], and post the tutorial here. I hope you enjoyed the contest! My previous ICPC-style contests: * [Oleksandr Kulkov Contest 1 in gym](https://codeforces.com/blog/entry/65678) * [Oleksandr Kulkov Contest 2 in gym](https://codeforces.com/blog/entry/72656) Compiled PDF Tutorial for all problems: [link](https://codeforces.com/gym/104234/attachments/download/19319/OKC3-tutorial.pdf). To make it worth a separate blog post, I will also add some brief meta comments :) P.S. Congratulations to the team **USA1** ([user:ecnerwala,2023-03-12], [user:ksun48,2023-03-12], [user:scott_wu,2023-03-12]) for solving all the problems in-contest! [cut]<br> ### [problem:104234A] Author: [user:adamant,2023...
casual manner. After all, I did a lot of save-load cheating with in-game casinos in Yakuza games :)

Full text and comments »

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

135.
By rabaiBomkarBittalBang, 3 years ago, In English
Codeforces Round #724 — Editorial We hope you liked the problems! If you’re curious about the two different problem formats, initially [user:Tlatoani,2021-06-06], [user:golions,2021-06-06], [user:qlf9,2021-06-06] and I were working on Omkar 3 with [user:antontrygubO_o,2021-06-06] while [user:hu_tao,2021-06-06] was working on a separate round with [user:isaf27,2021-06-06]. We eventually decided to join forces and combine the rounds, resulting in the current Omkar 3. <h1>[problem:1536A]</h1> Idea: [user:rabaiBomkarBittalBang,2021-06-06] Preparation: [user:rabaiBomkarBittalBang,2021-06-06], [user:Tlatoani,2021-06-06], [user:qlf9,2021-06-06] [Video editorial](https://www.youtube.com/watch?v=GZeihS2xTSc) <spoiler summary="Hint"> Consider what happens when $a$ contains a negative number. </spoiler> <spoiler summary="Solution"> We first claim that if any negative number exists in $a$, then no solution exists. Denote $p$ as the smallest number in $a$ and $q$ as another arbitrary number in the array (as $n...

Full text and comments »