We hope you've enjoyed the problems! (Certain problem editorials below may appear a bit late due to Polygon lag)
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | dXqwq | 3436 |
| 8 | Radewoosh | 3415 |
| 9 | Otomachi_Una | 3413 |
| 10 | Um_nik | 3376 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | adamant | 152 |
| 3 | Proof_by_QED | 146 |
| 3 | Um_nik | 146 |
| 5 | Dominater069 | 144 |
| 6 | errorgorn | 141 |
| 7 | cry | 139 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 9 | TheScrasse | 134 |
We hope you've enjoyed the problems! (Certain problem editorials below may appear a bit late due to Polygon lag)
Keeping track of both Codeforces round and online team contest was a doozy, so this is only the best draft of the editorial I have. Missing problems will gradually be added, and existing explanations may improve over time. Hope you enjoyed the problems, and let me know if anything can be explained better!
UPD: okay, all of the problems are out, and most of the bugs are fixed (I hope). By the way, we had a nice discussion with Errichto on his stream about Div. 2 problems, which some of you may find more approachable. Be sure to check it out, as well as other stuff Errichto creates!
(Kudos to Golovanov399 for his neat grid drawing tool)
Hello, Codeforces community!
I'm glad to invite you to Codeforces Round #691 (Div. 1) and Codeforces Round #691 (Div. 2), which will be held on 19.12.2020 12:35 (Московское время). The round will be rated for both divisions.
The problems were taken (mostly) from the ByteDance — Moscow Workshops Online Contest, which is happening at the same time. They were prepared by me, AndreySergunin, and amethyst0. We are very thankful to the testers: low_, kalki411, ecnerwala, Tima, IITianUG, thenymphsofdelphi, mohammedehab2002, namanbansal013, Redux for their time and great feedback. Also big thanks to Bytedance instructors chenjb and EvenImage for testing and reviewing the Bytedance online contest.
ByteDance is a global technology company operating a range of platforms that allow people across languages, cultures and geographies to create, discover and connect. ByteDance has partnered with Moscow Workshops and Codeforces to organize a top tier and exclusive training camp for the International Collegiate Programming Contest. The upcoming Programming Camp will be held in Beijing from February 20th to 26th, 2021.

ByteDance — Moscow Workshops Online Contest is an opportunity to participate as teams in this camp.
You can find more information about this training camp, including registration and prizes at https://programcamp.bytedance.com/.
Important update: please be informed that the Bytedance online team contest ends 25 minutes after the Codeforces round does. For this reason, we ask you not to discuss the problems publicly during that time, until 3pm MSK. Code and testcases public display will also be disabled during that time. Thank you for your understanding.
Scoring distribution:
Div. 2: 750-1000-1500-2000-2500-3000
Div. 1: 500-1000-1500-2000-2250-3500
Final update: thanks for participating, hope you had fun! Let's hear it for the winners:
Div. 1 (the only contestants to solve 5 problems):
Div. 2:
Here's a (now complete) editorial.
Happy winter holidays to all of you, and see you again on the leaderboards!
Heya! I'm going to stream my performance during ICPC Challenge 2020 on my Youtube channel. I'm not great at marathon-style but I'll see what I can do.
I know this is a competition with prizes which you generally can not stream, but ICPC people seem to be okay with this (in fact this wasn't my idea in the first place), so there you go. I still feel a bit weird about this, so I won't try to explain anything I do (help yourself and try to read my code if you want lol). To make it a little less boring, I'm down to talk to everyone in the chat. Drop by and say hello! Unless you want to focus on the competition of course.
Also check out the official Day Zero stream. GL&HF!
Thank you for waiting! I hope you've enjoyed the problems. Let me know what you think in the comments!
UPD: I almost forgot but here are some notes, as well as challenges for all problems. For a lot of them I don't have a solution and would be happy to hear your ideas.
Find a closed formula for the answer. For simplicity assume $$$a \leq b$$$,
As mentioned above, the problem is not that easy in general case when there are a lot of repeated letters. Still, is it possible to do? Any solution faster than brute-force would be interesting, or even some ideas or observations.
I find it much harder to create a good easy problem than a good hard problem. This position in paricular gave me a lot of trouble, we had to scratch three or four other versions. Not to say the result is very inspiring, but the previous ones were even worse...
What do you except to see in a good easy problem, say, up to Div1A? What are you favourite easy problems of this level? I would especially appreciate answers from high-rated coders.
How to minimize the total number of squares for a given $$$n$$$? The squares-on-a-diagonal construction in the first picture is pretty efficient, but e.g. for $$$n=4$$$ the picture in the sample has fewer squares. How does the minimum-square picture look in general?
How to find the smallest number of operations we need to make until there are no more we can make? Any solution polynomial in $$$n$$$ and $$$\log_2 \max A$$$ would be interesting.
It's not hard to construct a test where $$$n/2$$$ spots have to be closed. However, I could not find a test where more that $$$n/2$$$ spots need to be closed, nor do I know of a solution that closes less than $$$4n/7$$$ spots in the worst case. In other words, if $$$\alpha$$$ is the optimal constant such that $$$\alpha n + o(n)$$$ spots need to be closed, we know that $$$1/2 \leq \alpha \leq 4/7$$$. Can I find better bounds for $$$\alpha$$$, or even find its precise value?
Huge thanks to our tester kocko for pointing out many mistakes in an old version of this problem's statement, and even proposing a revision of a big part of the statement which we've adopted. Sadly, many other parts of the statement still were not very clear...
If the first player wants to minimize the number of turns until $$$R(n)$$$ lamps are lit, and the second player wants to maximize it, what is the resulting number of turns $$$T(n)$$$ is going to be? Precise formula would be awesome, but asymptotics or interesting bounds for $$$T(n)$$$ would be interesting too.
What are the minimum and maximum possible answers among all tilings of the board of given dimensions $$$n$$$ and $$$m$$$?
The final version of this problem is due to 300iq who proposed an interesting modification to my initial idea.
Can you solve the same problem in 3D? The breadboard is now an $$$n \times m \times k$$$ parallelepiped, and there are $$$2(nm + nk + mk)$$$ adjacent ports.

Hi!
On Jun/18/2020 17:45 (Moscow time) we will host Codeforces Global Round 8.
It is the second round of a 2020 series of Codeforces Global Rounds. The rounds are open and rated for everybody.
The prizes for this round:
The prizes for the 6-round series in 2020:
Thanks to XTX, which in 2020 supported the global rounds initiative!
Problems for this round are set by me. Thanks a lot to the coordinator 300iq and testers thenymphsofdelphi, Lewin, Golovanov399, Osama_Alkhodairy, gamegame, dorijanlendvaj, HenriqueBrito, kocko, ruban, Origenes, Ilya-bar, rahulkhairwar. Their feedback was a huge help and affected the problemset greatly.
The round will have eight problems and will last 150 minutes.
Scoring distribution: 500 — 1000 — 1500 — 1750 — 2500 — 3000 — 3500 — 3000+1500
Good luck, and see you on the scoreboard!
UPD: the round has concluded, congratulations to the winners:
Check current Codeforces Global series standings here (courtesy of aropan).
You can find the editorial here.
Stay tuned for prizes announcement!
How is self-isolation treating you? I recently found this channel with a guy solving Sudoku-like puzzles. Had a lot of fun trying to solve puzzles for myself, and then watching the pro do it ten times faster while explaining everything. That reminded me I didn't upload to my Youtube for a while, and gave a good impression of how things look from the other side.
So here's me solving an old AtCoder Regular Contest for practice. From my experience I can recommend trying to solve problems yourself before watching me do it. Wasn't in particular hurry this time, trying to explain my thoughts as good as I can. Let me know what you think, and enjoy!
We are aware about the issues with rating in Division 2. MikeMirzayanov is on it and will fix everything soon.
Congrats to the winners!
Technocup edition:
Div. 1 round:
Div. 2 round:
Analysis can be found here (if it doesn't show the analysis, just wait for a little bit).
Scoring distribution:
elimination round: 500-750+750-1500-2000-2750-3250-3750
division 2: 500-750+750-1500-2000-2750-3250
division 1: 500-1000-1750-2250-2750-3250Hi Codeforces!
This weekend, on Oct/26/2019 14:05 (Moscow time) we will hold Codeforces Round 596. It is based on problems of Technocup 2020 Elimination Round 2 that will be held at the same time.
Technocup is a major olympiad for Russian-speaking high-school students, so if you fit into this category, please register at Technocup 2020 website and take part in the Elimination Round 2.
Div. 1 and Div.2 editions are open and rated for everyone. As usual the statements will be provided in English and in Russian. Register and enjoy the contests!
Have fun!
A few people expressed interest in me answering some questions regarding competitive programming/problemsetting/related stuff. Since I have a bit of free time during these holidays, let's try this. I'll choose a few most interesting questions from comments under this post and try to answer them in a single video.
Ideally a question should not be to broad ("please give us some tips and tricks" is probably too broad) and possible to answer within a few minutes. I probably won't answer a question if it was asked a lot of times here on CF/quora/someplace else. Let's go!
On Oct/04/2018 10:05 (Moscow time), the Codeforces Round 513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2) will start. This is a special round for the Hello Barcelona Programming Bootcamp, in collaboration with Moscow Workshops ICPC. It is rated for all participants, everybody can register on it regardless of a rating.
Hello Barcelona Programming Bootcamp is sponsored by VTB and Indeed Tokyo, with the addition of team sponsors Phaze Ventures, Spark Labs and REMY Robotics.
VTB, the largest international bank based in Eastern Europe, continues to be an official partner of the Hello Programming Bootcamp series, adding further quality to the 3rd edition of the Hello Barcelona Programming Bootcamp by bringing their own participants, as well as by supporting top teams from around the world.
Indeed Tokyo is Japan's branch of the #1 employment website in the world, giving job seekers free access to millions of jobs from thousands of company websites and job boards. As they sponsor for the second year in a row, Indeed continues to offer the best job opportunities to the boot camp participants.
Wish good luck to all the participants!
There will be 8 problems, common for both division. Score distribution: 500 750 1250 1500 1750 2250 2750 3000.
The problems are prepared by me, Arterm and GlebsHP, with assistance from 300iq, ifsmirnov and vintage_Vlad_Makeev. Have fun!
Hello everyone! Today, on March 13 at 9pm MSK the second qualification round of Yandex.Algorithm 2018 tournament will take place. You can get to the contest page from the Algorithm site.
The problems are by me, Mikhail Tikhomirov. I am grateful to Gleb GlebsHP Evstropov for his help with problems preparation, and also ifsmirnov, halyavin, kuzmichev_dima, scorpion for testing the problems.
Good luck, see you at the competition!
Hi Codeforces!
The Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined) is going to be held on 05 Oct at 9:05 (UTC+2)! The round will be rated for everyone.
This round is organised in collaboration with 2nd Hello Barcelona ACM ICPC Bootcamp 2017 and supported by Sberbank, the biggest commercial and investment bank of Central and Eastern Europe, with over 175 years of history.
150 students from 53 universities, including ITMO, University of New South Wales, St. Petersburg State University, MIPT, Ural Federal University, Tomsk State University, Novosibirsk State University, Saratov State University, Samara National Research, Perm State University, and many other top global universities such as USA’s highest placing team, Central Florida University, along with Canada’s University of Waterloo, high-scoring Asian teams from Hangzhou Dianzi and Singapore, and Tokyo University, as well as Stockholm’s KTH, will be competing as individuals for the online round, which includes those of you from Codeforces!
The past week has been full of intense competitions, job interviews with Sberbank, and contest analysis and lectures by Andrey Stankevich (andrewzta), Mike Mirzayanov (MikeMirzayanov), Gleb Evstropov (GlebsHP), Artem Vasilyev (VArtem) and Mikhail Tikhomirov (Endagorion).
The event is completely international, as teams from all parts of the globe compete and practice side-by-side. They say a picture is worth a thousand words, so here is a selection to give you some idea of what’s happening at our boot camp.
And, once again, we can’t wait to see you all compete on the international stage, smoothing the road towards the April World Finals in Beijing.
The round’s creators are Endagorion, ifsmirnov, zemen and Arterm — team MIPT Jinotega, two-time medalist ACM-ICPC World Final (2016-17). The round is combined for both divisions, will contain seven problems and last for three hours.
Good luck!
Scoring: 250-500-1000-1500-2250-2500-3500
UPD: Thanks for participating, glory to the winners!
We will publish the editorial as soon as the Barcelona Bootcamp activities conclude.
UPD2: the English editorial is here.
A huge breakthrough in approximation algorithms was announced recently as asymmetric travelling salesman problem was shown to allow a constant approximation scheme. See discussion in an article by R.J. Lipton. One of the co-authors was Jakub dj3500 Tarnawski. It always pleases me to see competitive programmers achieving heights beyond CP, in academia and "real-life" problems (recall that OpenAI's bot recently beat human players at 1v1 Dota2, with meret and Psyho in the developers team). Congratulations on an outstanding achievement, Jakub!
A few people have been asking me for tips on practicing. Since explaining this many times is boring, I will be doing a live stream with a small practice routine: virtual round participation and upsolving the problems immediately after (maybe solving something else as well). I'll try to answer your questions as I go, so join in if you're interested.
The stream will start around 16:00MSK on Saturday, September 2nd on my Youtube channel.
UPD: sorry, the stream is going to start at 18:00, not 16:00.
Hello! I've been trying to install moj plugin on a topcoder applet in a new environment. The problem is I'm getting Exception in thread "AWT-EventQueue-2" java.lang.NoSuchMethodError: com.topcoder.client.contestApplet.common.LocalPreferences.removeProperty(Ljava/lang/String;)Ljava/lang/String;... when trying to save preferences of CodeProcessor, at this point:

Pressing the save button doesn't do anything except for raising the exception in the console. Does someone have any information relevant to resolving this issue? Thanks!
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!
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.
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 any operation made, and match them with their final destinations in the second string.
Both sets have to respect their relative order since we are not allowed to move them around. Hence, they have to form a common subsequence of the two strings. Note that if the solution made k operations, the common subsequence will have length n - k.
Moreover, we can make any common subsequence of size k into a solution that makes exactly n - k operations: just move all non-stationary characters to their destinations.
We can see that the minimal number of operations is exactly n - k, where k is the size of the longest common subsequence
... think about how the answer could be larger or smaller than this quantity, and try to reach a contradiction with the help of the previous spoilers.
Refer to the link above for the discussion of the O(n2) DP algorithm to the LCS problem.
Ok, nevermind.
Clearly, the number of occurences of each character must still agree in both strings. Further, it still makes no sense to move the same character twice. Further, the stationary characters still have to form a common subsequence. However, the second sample case shows us that the answer can be greater than n - LCS(s, t).
Consider a stationary character si and its destination counterpart in the second string tj. Respective to si, we are only allowed to move characters from right part of s to the left.
Consider a symbol x. Count its occurences to the right of si and tj, denote the counts A and B. The above reasoning must imply A ≥ B. For si and tj to be possibly matched, this condition must hold for all symbols.
A reasonable line of action is to implement the DP solution for LCS while requiring the conditions above. But are the conditions strong enough to allow only valid solutions (that is, stationary sets of characters that can be extended to a sequence of operations)?
It may not be easy to prove or disprove right away. This is a totally OK situation, even for experienced participants.
If you have a plausible guess that you can't prove but have to confirm, a good idea is to stress test it: implement a brute-force solution that is sure to be right, and check if it agrees with your hypothesis on many random cases. If it does, you are very confident that the guess is right, and if it doesn't, you have a counter-example and can investigate further.
Happily, yes!
We have to prove that a satisfactory common subsequence of length k gives rise to an operation sequence of length n - k, or, equivalently, that all non-stationary characters can be moved to correct positions. If there are no stationary characters, then everyone can be rearranged in any order with one operation per character, hence we are done.
Consider the rightmost stationary pair si and tj, and the character collections A and B that lie to the right of si and tj. We must have that
in the sense that no character occurs more times in B than in A. We can easily obtain B in the final configuration by choosing an equal sub(multi)set in A and arranging them in the required order while staying to the right of si.
What should we do with all the rest elements A' = A\ B? We must spend one operation per element of A' to move them to the right of si into their final positions. However, we may as well postpone the decision and "merge" A' with the next group of characters to the left of si. We then continue with the new rightmost group, and so on until there are no stationary characters left.
Can you solve the problem much faster than O(n2), or provide hard evidence that a faster solution does not exist?
The problem is closely related to the LCS problem. What does the world know about the complexity of LCS? If we were to show that this problem is at least as hard as LCS, how would we do that?
I will post the solutions to challenges at a later time, enjoy solving yourself for now. =)
Topics: greedy.
Summary: a gatekeeper for inexperienced and/or impatient contestants. Many details to take into account, but otherwise tractable.
Solution: Since we aim to maximize the number, let us look what is the largest first digit we can possibly place. Let d denote the first digit of n.
In case 1 we can place y, in case 3 we can place x, and in case 5 we are forced to make the number shorter by one digit (effectively, placing 0). Since the new number is already compared less than n, the rest can be maximized without restraint, that is, filling with y's.
If d = x or d = y we may have a chance to match the first digit. However, we cannot tell right away if the first digit can be actually extended to a complete number that does not exceed n, e.g. n = 20, x = 1, y = 2.
We may proceed over digits of n until we meet a digit d' other than x and y, or the end of the number. In the latter case, the answer is just n.
If d' > x, then the number can be extended to the end (refer to the initial rule for the first letter). If d' < x, the number can not be extended further and we have to roll back and make some of the eariler digits smaller.
Naturally, we can only decrease y to x, hence we find rightmost placed y, change it to x and maximize the rest of the number (since we placed smaller digit at an earlier point).
It follows that n starts with x and proceeds with a digit smaller than x. We can see that there is no satisfactory number of the same length, hence we should decrease the length.
Come on, this is easy to come up yourself (or find in the above spoilers). I mean, seriously?
One can see that this is an O(n) solution since we make at most one backward pass, and at most two forward passes.
You may want to check the following:
How many (modulo 109 + 7) positive numbers are there that consist only of digits x and y and do not exceed n? Solve in O(n) time.
I will post the solutions to challenges at a later time, enjoy solving yourself for now. =)
Topics: hashing/string algorithms.
Summary: while this is a simple problem, some approaches are better than others in terms of complexity, memory, and implementation tediousness. Pick your poison!
Solution: As a start, how can we prove why the Fibonacci sequence as described in the statement is not 1-recursive?
Then there must exist a function f(x1) such that f(ai) = ai + 1. But then we must have simultaneously f(1) = 1 and f(1) = 2, a contradiction!
Indeed, suppose that any occurence of a number x is followed by the same number y (or the end of the sequence). It means that the function defined by f(ai) = ai + 1 has no contradiction, and the sequence is 1-recursive.
We can see by now that k-recursiveness is all about non-contradicting continuations of k-tuples: if there are two consecutive k-tuples of elements followed by different numbers, then the sequence is not k-recursive. Otherwise, the function defined by f(ai - 1, ..., ai - k) = ai is consistent.
We could do that explicitly by writing out all k-tuples along with the subsequent elements, and check for conflicts. This takes O(n3) time when done explicitly,
time if we sort the tuples and compare only the adjacent pairs,
time if we hash the tuples beforehand using the rolling polynomial hashes.
The rest of the solution is binary search on k, with the resulting complexity
, or
.
Solve the problem:
with simple string algorithms (no hashes!)
with harder string algorithms (no hashes either!)I will post the solutions to challenges at a later time, enjoy solving yourself for now. =)
Topics: greedy, sorting, implementation.
Summary: while the solution is not exactly evident from the start, one has to jumps a lot of hoops and dodge a lot of spikes to avoid all possible mistakes with precision, query limit and whatnot.
Solution:
Suppose that we're willing to spend some amount of goods so that vendor's perceived price is a small ε.
Suppose that we choose to spend only i-th good, then we have to spend ε / di, with our perceived value being ε·ci / di. Hence, it is optimal to choose the good that minimizes ci / di.
Breaking x into small ε portions and applying the previous argument, we can see that we should gradually use goods by increasing of ci / di until the vendor agrees to sell. Note that goods with equal ci / di can be taken in any order.
According to the considerations above, it is beneficial to know the order of goods sorted by ci / di.
A key idea is that it is unnecessary to know the values of ci / di, but only be able to compare them.
Our query capacity is very limited: a simple YES/NO answer, that we have to apply to precisely comparing numbers. A correct way to do this would be to obtain a configuration with
with high precision, and then make alterations to it so that the balance is decided on ci / di comparison.
Simply make all ai equal and binary search on their common value. About 40-50 iterations should result in a practically precise double value (more on precision issues below).
Let us choose a small, but positive Δ. To compare fractions for i-th and j-th goods, alter the balanced configuration by performing ai - = Δ·cj, aj + = Δ·ci. The value of
will be changed by the value of
, which has the same sign as ci / di - cj / dj. Note that comparison takes only one query (except for the equal fractions case which may be undecided as of now, more on that later).
Since we now know the order, we can binary search on the total volume of goods we're paying. Greedy considerations above tell us to distribute them greedily from the lowest ci / di to the highest.
The resulting solution makes roughly
queries, in practice this number is about 450 on the present constraints.
This pretty much concludes the idea description.
The only constraint is that we can't choose Δ to be too large since we may over/underflow ai. We know that the common value of ai in the balanced configuration will be at least 0.1 away from the borders. To keep the alteration within this distance we have to satisfy Δ max(ci) ≤ 0.1, hence Δ ≤ 10 - 5 is pretty much fine.
Note that the value of
will be
away from x provided we are comparing distinct fractions, hence we are free from precision problems at this point.
This is a bad spot to be. One possible situation when this issue arises when you're using std::sort to sort the fractions with the custom comparator that makes the queries itself. std::sort likes to make additional comparisons to check certain properties of your comparator, such as transitivity. Not only that provides an overhead on the query number, but can also lead to RE if your comparator does not behave well on comparing equal objects: it must always return false on equals.
The reason why our comparison is bad for this prupose is that the value of
changes ever so slightly when add practically zero number to it, so that it can dance around x and returns random values on comparisons (note that there is no tolerance in ? query!).
One solution would be to make
slightly larger than x so that not to suffer from precision fluctuations (warning: this can break most of the present analysis, do at your own risk).
Note that most sort algorithms are resilient to this kind of problem (e.g., merge or insertion).
Can you solve the problem in
queries, where A is the maximal value of ci, di?
I will post the solutions to challenges at a later time, enjoy solving yourself for now. =)
Topics: maths, shortest paths in graphs.
Summary: even if you don't come up with a simple mathematical solution, graph algorithms save the day. Easy!
Solution:
We can construct a graph with vertices for each configuration (x, y, d), where (x, y) is the current point, and d is the direction last travelled (note that we only need to remember if the direction was horizontal or vertical). Assuming that we never leave the square with coordinates bounded with 100 by absolute value The graph has < 200 000 vertices and < 400 000 edges, hence we can find the shortest path with a simple BFS.
Denote Δx and Δy the absolute differences of x and y coordinates respectively.
.
Without loss of generality, suppose that Δx ≥ Δy. First, we cannot make less than
moves. Indeed, we have to make at least Δx horizontal moves to get to the finish, and, because of alternation, at least Δx - 1 vertical steps. We also change the parity of sum of coordinates after each step, and that determines the parity of y-steps.
Second, this number of steps is enough. To see that, first travel to the point (Δy, Δy) in 2Δy steps with a repeated UR step pattern, and then repeat the RURD pattern until you reach the target. One can check explicitly that the lower bound on the number of steps is reached exactly.
How to solve the problem if we are travelling in k-dimensional Manhattan, that is, the position is given by a k-tuple of integer coordinates, and we're allowed to change one coordinate at a time, and must change the "streets" (coordinates we change) after each step? Solve in
time.
I will post the solutions to challenges at a later time, enjoy solving yourself for now. =)
Topics: game theory, graphs, math.
Summary: frankly, I anticipated a lot more solutions on this problem. All ideas seemed basic to me, and the code is very easy. Still, it seems that cracking the whole thing was not that simple. Did you enjoy solving it? =)
Solution:
For the, say, Red player we must have kR = vR - eR, where vR is the number of red vertices, and eR is the number of edges with both endpoints red.
Red player wants to maximize kR - kB, which is equal to (vR - eR) - (vB - eB) = (vR - vB) - (eR - eB). Note that vR and vB are independent of the players' actions, and
. It follows that the equivalent game would be to minimize eR - eB.
Let us keep a counter on each edge. When Red player moves to a vertex, all counters of incident edges increase by 1, and when a Blue player moves, all incident counters decrease by 1.
On one hand, the is clearly (sum of degrees of Red's vertices) — (sum of degrees of Blue's vertices).
On the other hand, a red edge (with both endpoints red) has +2 on it, as a blue edge has -2. A neutral edge has 0 on it. It follows that the same total is equal to 2(eR - eB).
The above discussion implies that moving to a vertex of degree d effectively gives you d / 2 penalty against your score.
It is now clear that the optimal strategy is to always move to a free vertex of the lowest degree, regardless of any previous actions.
This is easily implemented into a clean O(n) solution.
How to play this game on a unicyclic graph (a connected graph with n vertices and n edges)? What can you say about complexity in the case of a general graph?
I will post the solutions to challenges at a later time, enjoy solving yourself for now. =)
I'll be glad to hear all your opinions in the comments. Thanks for participating!
Hi!
It is my pleasure to inform you that today, on June 4 at 15:00 MSK the third and final elimination round of the Yandex.Algorithm 2017 championship will take place. I'm equally pleased to tell that the problems of the round were prepared by me, Mikhail Tikhomirov. I worked for Yandex for three years, and had a great time in a friendly and professional team. Cheers to Yandex!
This round wouldn't take place if not for the work of these great people:
Lidia lperovskaya Perovskaya and her team who are responsible for the Yandex.Contest system,
Maxim Zlobober Akhmedov, previously a vigilant Codeforces coordinator, and currently a vigilant Yandex.Algorithm coordinator,
Mike MikeMirzayanov Mirzayanov and the Codeforces crew who support the Polygon problem preparation system,
and finally, all Yandex employees who took part in testing the problems of the round (sadly, the margin of this blog is too narrow to contain all their names).
The round will feature the standard scheme: 6 randomly shuffled problems for 100 minutes with TCM/Time ranking system. The last GP30 points will be distributed judging by the round results, and the final round advancers will be determined at last (find current scoreboard here). You still have the chance to advance even if you missed the previous rounds!
An editorial will be published in a separate blogpost after the round is concluded. We wish good luck to all participants, and hope you enjoy the problems!
UPD: the start is delayed by 15 minutes for technical reasons. Sorry for the inconvenience!
UPD2: the round is finished! Here be editorial.
Yesterday, on April 23 an Open Cup round — Grand Prix of Moscow Workshop was held. In fact, the same contest was held on April 17, the last day of Moscow Pre-Finals ACM ICPC Workshop.
The problems were prepared by the workshop programming committee: Mikhail Tikhomirov (Endagorion) and Gleb Evstropov (GlebsHP), as well as members of MIPT teams Jinotega: Ivan Smirnov (ifsmirnov), Artsem Zhuk (Arterm), Konstantin Semenov (zemen), and Cryptozoology: Alexander Ostanin (Kostroma), Alexander Golovanov (Golovanov399), Nikita Uvarov (-imc-). We hope you enjoyed solving our contest!
The results can be found on the Open Cup page. Our congratulations to teams SPb ITMO University 1 (Belonogov, Zban, Smykalov) and the veteran team SPb Havka-papvsto (Kunyavsky, Kopeliovich) on solving all 11 problems! Please not that since Java issues in Yandex.Contest are not fully resolved yet, the results are not final and Java submissions may be subject to rejudge.
Here is a link to PDF editorial for the problems, prepared by myself and GlebsHP. Please ask your questions and point out the mistakes in the comment section.
Sorry for the wait! We'll be glad to answer your questions in the commens.
| Name |
|---|


