pikachu_1234, mVpick and navneet.h are trying hard to invite me to their team. I rejected this invite 5 times already.

So, guys, you wanted my attention, here it is.

I can't really think of good solution to prevent such behavior. Maybe someone can?

# | User | Rating |
---|---|---|

1 | Benq | 3539 |

2 | tourist | 3532 |

3 | wxhtxdy | 3425 |

4 | Radewoosh | 3316 |

5 | ecnerwala | 3297 |

6 | mnbvmar | 3280 |

7 | LHiC | 3276 |

8 | Um_nik | 3260 |

9 | yutaka1999 | 3190 |

10 | TLE | 3145 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 192 |

2 | Radewoosh | 179 |

3 | tourist | 173 |

4 | Vovuh | 167 |

4 | PikMike | 167 |

4 | antontrygubO_o | 167 |

7 | rng_58 | 160 |

8 | majk | 157 |

9 | Um_nik | 154 |

10 | 300iq | 153 |

pikachu_1234, mVpick and navneet.h are trying hard to invite me to their team. I rejected this invite 5 times already.

So, guys, you wanted my attention, here it is.

I can't really think of good solution to prevent such behavior. Maybe someone can?

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Hello!

I'm glad to invite you all to Round 576 which will take place on Jul/30/2019 17:35 (Moscow time).

There will be 6 problem in both divisions.

Round is based on Team Olympiad in Computer Science Summer School. It is (yet another) summer school for schoolchildren organized by Higher School of Economics and "Strategy" Center in Lipetsk. Almost all the problems are authored and prepared by teachers and teaching assistants in CSSS: Um_nik, Burunduk1, I_love_fake123, MakArtKar, Villen3tenmerth, Aphanasiy, Gadget. One of the problems is authored by Merkurev (just because we are friends :) ). One more problem for the round was added by KAN.

I would like to thank KAN for CF round coordination, I_love_Tanya_Romanova, Merkurev, Rox and tractor74.ru for testing, and Codeforces and Polygon team for these beautiful platforms.

Scoring will be announced.

Upd: We added one more problem to div.1 contest, now both contests have 6 problems (4 in common). The round is not combined, if it were, I would write "combined" in the title.

Scoring distribution:

div2: 500-750-1250-1750-2500-3000

div1: 500-750-1250-1500-1750-2250

Congratulations to our winners!

div.1:

1. Radewoosh

2. tourist

3. mnbvmar

4. Benq

5. pashka

div.2:

1. ChthollyNotaSeniorious

2. Honour_34

3. ldxcaicai

4. shogunator

5. Yatsumura

Editorial won't be published.

Announcement of Codeforces Round #576 (Div. 1)

Announcement of Codeforces Round #576 (Div. 2)

How do I choose contest for practice: go to Gym, set difficulty to 4+ and duration to 5h, look through the list. In some of the contests I already participated, it is clearly visible in the list.

Problem: On the top there are other contests I don't want, I have to skip them every time and this list is growing. Why would I not want given contest? Maybe I participated on a different platform, or maybe difficulty is not right for me, or maybe I want to leave it for later team training.

Obviously, CF cannot detect any of these issues. But maybe we can have button "don't show this contest for me", just like Fav button? MikeMirzayanov

Another (less useful for me, but maybe more useful for community) possible feature is to allow users with coach mode to change difficulty settings. C'mon, low red get total in 4h, how is this a 4 star.

Hello Codeforces!

Sadly there will be no OpenCup round this weekend, but instead I invite you to participate in a mirror of t.me/umnik_team Contest which will be held on Timus Online Judge this Sunday, 12 MSK. This contest was originally held on Petrozavodsk Summer Camp 2018 (if you participated in the camp, please do not participate in this contest). This is an up-to-3-person team contest with ICPC rules (one computer per team). Difficulty level is comparable to OpenCup rounds (not TooDifficuIt-hard, but certainly not for Div.2).

Author of most of the problems is me, with huge help from Merkurev and one problem from Kronecker.

Hope you will enjoy the contest.

Last three blogs on main page of CF shouldn't be on main page. And it become quite common thing in recent CF practice. Main page should contain only something that all users should see. Of course, round announcements, platform upgrades and sponsor posts should be on main. Blogewoosh had some rights to be on main because it was cool series of blogs which had chosen CF as its platform so CF should have praise it (but it would be nothing wrong for it to be just in Radewoosh's posts like everything else). But all other stuff? Let's look at some examples for the last year.

Important: I'm not saying that these blogs are bad. Most of them are good. But why are they on main page? CF have great blogs system, every user can write something helpful. Just don't put random stuff on main.

Some algorithm stuff which is better than other algorithm stuff, I guess:

C++ STL: Order of magnitude faster hash tables with Policy Based Data Structures

Linear Recurrence and Berlekamp-Massey Algorithm

[Tutorial] Searching Binary Indexed Tree in O(log(N)) using Binary Lifting

Don't use rand(): a guide to random number generators in C++ — this one is kinda mandatory for participating in CF rounds due to bad compilers on CF, so it is good that it was on main

Blowing up unordered_map, and how to stop getting hacked on it

Random contests in gym which are better than other contests in gym, I guess:

Original Gym contest: Geometry Special 2018

2018-2019 ACM-ICPC, Asia Xuzhou Regional Contest (Online Mirror on Gym)

ROI 2018 in GYM

Promoting Errichto, I guess:

Stream

Sums and Expected Value — part 1

Lecture #3 — Exchange arguments (sorting with dp)

More sponsored stuff??

Анонс кружков от tinkoff.ru

My Course at Harbour.Space University: Advanced Algorithms and Data Structures (January, 2019) — selfpromotion, also nobody should pay 1000 euro for a course no matter what this course is. This is just abusing position as Codeforces CEO

IDK

Lunch Club at ICPC WF

The D programming language in competitive programming

Codeforces Contests Picker Goes Live: Celebrating ICPC Season

Team dashboard

Let's bring souvenirs to the ICPC World Finals

Unnecessary blogs on main

MikeMirzayanov's personal blog:

Hello, ITMO! — yes, there are some inforamtion about platform improvements but it is just an excuse to write this post

Codeforces Round #547 (Div. 3) — round announcement? Um_nik is totally crazy. Well, yes, but the photo and "I'm so cool I made a round in 6 hours" is nonsense. Also how about wait in line for half a year like others do?

It looks like it is just a question of whether Mike saw and liked the post. MikeMirzayanov, CF main page is not your personal blog. Please don't use it as your favorite tab.

Someone suggested recording screencasts, I made a poll in my telegram channel (Russian only) and the idea was positively accepted. So, here is my first screencast. I think I will be doing them on every round (if possible) while someone is interested (because it is easy, just 4-5 clicks).

I know that some people would like me to do commentary, but on live rounds I'm trying show my best performance, so it won't happen. But you can suggest some things and maybe I'll do something.

I read Russian problem statements on screencast (because it is more convenient for me), but the code is in C++/Python, so it shouldn't be a problem.

UPD (10.01): I uploaded Hello 2019 screencast and almost uploaded round 530 screencast. I had bad internet connection when I was solving the contest, so I upload only now. Normally I will upload screencasts no more than 30 hours after the contest, so if you are interested in watching it, just go to my channel. I won't make updates like this in the future.

It is this time of year! Many people trying to summarize all the things happened during the year. And since I love to hate people, I want to make a vote for most annoying person on CF in 2018.

I know that I'm in top contributors list for too long, so to vote for given person you should **downvote** the comment with this person's handle(s). Due to the nature of voting through comments on CF, you can vote for many people, and you can also upvote comments if you find given person's comments helpful/funny/positive.

If you care for your contribution but want to nominate a candidate, you can PM me their handle(s), then I will write a comment to vote. Note that I **will** write that it was you who nominated this person, so it saves your contribution but not relationships with the nominee. I will ignore messages from people without rating.

If you hate someone already nominated so much that you want them to know, you can also PM me so I'll add you to list of people who nominated given person.

Obviously, you can nominate someone with your own comment, but watch out for downvotes.

Also, you can try to increase your contribution by nominating some very nice people unanimously loved by community. In that case I will nominate you right after that.

I know that I'm obvious candidate, especially after writing this post. But I don't annoy me, so go on and show me your hatred :)

Love you all, Um_nik.

Here are our champions:

-515 Numb

-316 riela

-264 MikeMirzayanov

-236 I_love_isaf27

-224 CodingKnight

-198 adamant

-166 MikhailRubinchik.ru

-143 kostka

-135 300iq

-135 I_love_isaf28

-134 I_love_i_love_isaf27

SharpIJustWantNegativeContribution

В этом году я не участник и не тренер, и в Питер не поехал, поэтому решил провести очень неофициальную трансляцию NEERC. Да, я буду тупо 5 часов жать F5 и иногда что-то говорить.

Ключевые особенности:

- не Снарк

- нет админки контеста

- не умею стримить

? нет обсуждения задач (не хочу их себе спойлерить)

? ярковыраженное обожание Moscow SU Red ?an?a

? скорее всего нецензурная лексика

? Руссиан ленгуаге

+ не Виталик Аксенов

+ нет интервью с Парфеновым и другими уважаемыми людьми

+ буду читать чат

+ в кадр будет заглядывать милейший песель

Скорее всего, будет скучно, но если вы все равно собираетесь следить за ходом контеста, то почему бы не делать это с очень непрофессиональной трансляцией, когда есть типа профессиональная.

Чтобы убедиться, что ничего не работает, в 17:30 (время Московское, это примерно через полчаса от публикации блога) начнется тестовый стрим, и я планирую в 18:00 начать виртуальное написание Lyft Level 5 Challenge 2018 — Elimination Round с лайв комментариями о том, что я пытаюсь делать. Опять же, язык русский. После стрима можно попытаться заставить меня порешать что-то еще.

Ссылка на канал: https://www.youtube.com/channel/UC3-pkjZ8-D4aW8QfaExuMjw

Подписывайтесь, ставьте лайки на все 0 видео, жмите колокольчик, воруй-убивай.

I wanted to write super-harsh blog but then I decided to split it into educational part and whining part. This is whining part. To read some cool stuff go here. This one will also be educational on a slightly different topic. And there will be A LOT of harsh stuff.

I'm not saying that I'm perfect. That round had some really bad problemsetting issues. Problem E was googleable, problem D had very weak tests against very stupid solution (so stupid that none of the authors and testers come up with it, moreover, it is so counter-intuitive that I don't know how so many people independently did it). In two constructive problems participants could look at jury's output, the feature of which I didn't know. And I'm sorry for these issues. BUT. This comment has very negative rating despite being so true. And no one are here to back me up. So I want to speak my truth as I always do.

Let me accompany you to the world of supposedly BAD STATEMENTS. aka statements written by Um_nik.

Problem C from 2nd division of CF Round #518 gets a lot of praise for having very bad statement. Let us look at clarification requests we get on this problem. My answers here are not answers to clarifications from real contest, they are my emotions.

I think that you should be ashamed for your clarifications so I will include handles. This is probably not ethical as a problemsetter to do it. But I don't care anymore. Maybe I will be banned from setting rounds on CF. That looks like a good thing for all of us. You don't want to solve my problems, I don't want to do anything good for you.

"Is it also necessary that if 2 colors harmonize each other they should be connected?" and similar

by sam29, arif.ozturk, aman28rwt, ryansee, Vshining, Gritsaev, goyal_sidds06, Huvok, seo, Nordway, Apptica, yuricardoso, sparsheatu, iGotMyEyesOnYou, ddeennyyss, chrome, SecondHandle, cjc, math_codet, GhostDrag, GhostDrag

Answer: Yes. That's what "if and only if" means. Literally. That is the meaning of these words.

"Excuse me, what is number k in prob C?"

by Gritsaev, dungdq2002, ddeennyyss

Answer: That's a good question, number k is not important for the problem, but I decided to introduce it to ensure that you'll understand that you should place only colored rooks on a chessboard.

"A,B harmonize; B,C harmonize; do A,C Harmonize?"

by harshit601, Fighter.human, Gudleyd, atrophy98, tshr

Answer: No. I have no idea where did you get it from. There is nothing resembling in the statement. Probably it's an attempt to explain some samples, but it is wrong on first sample.

"are there many solutions for sample tests or it's one solution only?"

by MohamedAhmed04, XMORE, __P_K_B__, mahdibuet3

Answer: Another good question, we made global clarification about this later. This was obvious from the samples, I think, but it was a mistake not to write it. I'm sorry.

"In the first sample, we can't go from the blue rook to every green rook!!" and similar

by cfalas, OmarBazaraa, showoff, DesiChamp, cjc, aman_shahi2, DesiChamp, showoff, S.Jindal

Answer: Samples are correct. Statement is correct.

"Reply fast please"

by chan_iitp

"The statement looks like it was done with google translate, i don't understand anything"

by AlexArdelean

Answer: That's important information.

"if there is a harmonized pair (a,b). do the ans must contain a set of union of a and b? or i can arrange without any union set."

by sparsheatu

"if there is a harmonized pair (a,b). is it a must to make the both set of color a and b connected?" by sparsheatu

"And any rook of one color is connected with any other rook of another color that means all rook of 1st color is connected with all other rook of 2nd color if both color harmonise with each other?"

by Fighter.human

"Is it necessary for two rooks of different colors to be in one set?" by bktl1love

"What is harmonize of color??"

by Infinite_S

"can i connect colors other than the described in the input"

by KyRillos_BoshRa

"Specail Judge?"

by C20192413

Answer: Do you fucking read your questions? I like that "I can't solve the problem with operations in statement, can you provide better operations for me?"

Many questions just asking to clarify what the hell is happening in this hellish statement. There are a lot more stupid questions, I just tired.

CF has a large number of participants in each round. If 5% of participants think that his/her time is more important than ours then we will have to answer 5-10 questions every minute. In this round we had 30-40 unanswered questions during an hour, waiting time to get answer to your question is 5-10 minutes. And if we can't understand your question, we spend several minutes on answering. Please. Please. PLEASE. Spend 2-3 minutes trying to answer your question yourself. Use samples. Reread the statement. This is a skill, you have to improve it. Read my blog.

Don't ask "please explain the problem, I don't understand it". We already did explain the problem. The thing called "statement". Read it. Carefully. Why do you think that we will come up with better explanation right now? We prepared this statement several days, we asked testers to read it and say if something is unclear.

Don't say that statement is bad because you can't understand it. The statement can be hard to understand because it requires some knowledge, not because it is badly written. And some statements require to know mathematical notation like "if and only if" in this particular case. I can't come up with better explanation of why there are so many people asking the same question. basically "what if and only if means".

Please assume that authors spend some time on your contest. Much more time than yours 2 hours. Because it is true.

You can remember that once I made round unrated because I found the mistake in authors solution. I didn't wrote a clarification "I think your problem suck" without explanation. I continued my attempts to solve the problem and waited for the end of the contest, then asked what is authors answer for my test. Because I expected that authors did their job well and too busy answering stupid questions during the round.

One more time I spend ~15 minutes trying to prove that my answer for sample is incorrect. When I did it, I send this clarification: "Are you sure that answer for third sample is 34? For me it seems that there are 3 valid trees, in each of them there are 6 possible ways to choose pair of vertices, and for each path there are two possible winning moves for Ember, so the answer should be 36." Compare this to what you do.

I also think that CF should abandon the practice of answering every clarification if possible. It will decrease the number of clarifications and decrease the time to answer one clarification. If I can answer "Read the problem statement", that should be the answer. If I can answer "No comments", that should be the answer.

I think I'm finished with whining about my statements. Now about this doomed community of supposedly smart people.

The thing you did called bullying. There are people who downvote everything I write independent of content. Next there are people who disliked the consequences of my words, even my comment is correct. And there are also people who don't like that I'm saying my thoughts and don't respect their idols.

I liked first comment about "should stop creating problems", and first comment about this after the round. All others don't have own thoughts and have to repeat one thing over and over again. Now it is not a joke, it is being animals.

The same goes for "mind is weak". Yeah, guys, you are so original, it was not me who said it first.

To adequate people in this community: I'm tired of speaking truth. This not your truth? Explain me why am I not right, change my point of view. You think that I'm right in some cases? Speak it up. These animals can attack lone people, but if they will see that I'm not alone, they could think for once. You think that I have no right to insult people, but the idea is correct? Downvote me, say that wording is bad, but express that you agree with meaning.

MikeMirzayanov, I understand that for you quantity is more important than quality. I'm happy that you have your army of stupid fanatics who will write "You forget to hail Mike" under each post. This army has defeated me. Congrats.

But Um_nik, 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!

- 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 possibilities.
- Samples are part of problem statement. After building math model, check that you model working correct on samples, at least on small samples where you can check everything fast.
- Notes are part of problem statement.
- Try to find familiar patterns, maybe objects you already know something about. If you are given some connected graph with exactly one simple path between each pair of vertices, it's called tree. 4 letters instead of 12 words, see?
- Try even harder to spot something strange, something you not expecting. That probably will be the cornerstone of the problem.
- If there is some part of the statement you don't like, try to change that to something you like. Start with understanding the object, then simplify it. There are some problems which can be completely solved by this technique.
- If the model you get is very big, try to split it into some pieces. It would be great if pieces are independent, like 'solve problem1, then use its answer as input to problem2 and so on'.
- On first stages it can be useful to write your new statement. On paper. By hand.
- Problemsetters do not write random things in statements. But why would you believe me, since I'm a bad problemsetter? I don't know, maybe you shouldn't.

I'll use Timus for almost all examples. If you see statement in Russian and you don't want to, there is a language switch in upper-left corner.

Assumed workflow: read the statement on Timus, try to understand and simplify it using the rules above. You don't have to read "solution" parts, but I warn you that my concept of reading statements works. I mean, "statement" parts will often contain huge hints to solution.

In most cases I won't write step-by-step explanations how I get the final version. You can say that that's not how teaching works. I can say that you don't want to study. I'll win, because that's my blog.

Given undirected graph, find its spanning tree with minimal diameter.

Diameter has exactly one center. Let's fix the center, it's either vertex or middle of edge. For fixed center the tree with minimal diameter is a tree with minimal height if it's rooted at center. Run BFS to find it.

Given a tree, each vertex has some subset of universe of size *m*. Find such a path that disjoint union of subsets of vertices on this path is universe.

Something with hashes and mergeable sets. It's not cool, so I won't spend time.

Given an undirected graph with at most 14 (small=important) vertices. Build a bipartite graph: left part is vertices, right part — all simple cycles. Find the minimal number of matchings to cover all the edges.

After that reduction it is kinda known problem, you will also need some subset DP (see? small=important) to calculate needed values.

Count the number of complete subgraphs. Nice and easy. Oh, doesn't work on samples? Yeah, +1, because it's the first day they won't find new complete subgraph. Whatever.

Calculate number of *m* ≤ *n* such that *gcd*(*a*^{2} + *m*^{2}, 4(*a* + *m*)) ≠ 1. Wow, it is not geometry, it is number theory problem?! Who would know! Except, like, anyone who read the problem statement.

Now I'll try to explain something.

Wait what? Sum of distances? Circular strings? Sounds hard. But actually this problem is much easier for circular strings. Let's try to change sum of distances to something nicer. We compare some pairs of characters and add 1 to sum if they're different. What pairs? Well... all pairs. All pairs exactly once.

We have some strings with blanks, and we want to fill blanks such that number of pairs of different characters is minimal.

We kinda already did solve. It is obvious that if we have blanks only in one string, we should fill all of them with most frequent character in the other string. Applying this to any solution we get that in each string all blanks are filled with same characters. If they are different for two strings, they should be chosen independently and be the most frequent character in the other string except blanks. If they are equal. we can try all the possibilities.

This looks terrifying. Let's start unravelling. What are our possible actions? Add one plate on top or remove topmost plate. Sooo, first in last out. That looks like stack. That's exactly stack.

That's a good start. So we have a stack and *n* types of things we can put in stack. But there are also some timetables which describes our actions. And we should count the number of this timetables...

What if we look at it from the other side? We have a timetable and use a stack to model actions described by a timetable. Don't we have something similar that we already know?

Here you need some experience and some *magic*, but sooner or later you'll understand that timetable is correct brackets sequence with *n* different bracket types.

OK. Now the problem operates with some familiar objects. We have to count the number of correct brackets sequence of given length, and there is also some conditions on what brackets can be opened at any given time. And the number of bracket types is not greater than 10 which kinda presumes using mask as a DP state.

We are only interested in weekdays, so basically we are living modulo 7. 7 is prime, that gives us hope. Each sort of honey takes some fixed but unknown number of days to eat. Let's call them *x*_{i}. And we have some information about... linear combinations of *x*_{i}? In form of equations modulo 7 i.e. in the field? Cool, it is a problem about gaussian elimination. And number of queries is convenient! Going through statement once more confirms: all we have to do is maintain basis of some system of linear equations and check if new equations already can be expressed as linear combinations of old, this also handles the consistency part.

We didn't do anything besides reading the statement and we solved a problem with difficulty way beyond 2k.

Given square matrix of size *n* ≤ 100. Check if there exists a vector with some non-integer coordinates which after multiplying with the matrix becomes all-integer.

WHAAAT. Did you even read the statement, Um_nik? There is something about rings, and rotation, and magic, and... WHAAAT. This is certainly some magical geometry, not linear algebra.

Go and read it again. And again.

Now we can talk. Let's denote the number of full rotations of *i*-th accessible ring by *x*_{i}. It can be negative, it can be non-integer. Let's denote the number of full rotations of *i*-th protected ring by *y*_{i}. (maybe *A*_{ji}, it is not really important). Yes, that's multiplication of matrix by vector. And yes, we want *x* to be non-integer and *y* to be integer. Now go and read the statement again.

Let's assume that if the solution exists then exists the solution with rational *x*. It can look suspicious, but after some thinking you understand that irrational summands should somehow balance themself out, because we want rational values in the end. I don't remember the proof :)

Let's say that common denominator of all fractions in *x* is *Q*. Then is we multiply *x* by *Q*, two things will happen: *x* will become integer but not all coordinates are divisible by *Q*; *y* has all coordinates divisible by *Q*. Or, in other words, we take non-zero vector modulo *Q* and get zero vector modulo *Q*. Or matrix rank modulo *Q* is less than *n*. Or determinant modulo *Q* is 0. Well, we should *calculate* determinant modulo *Q*, not just take determinant and then take the remainder modulo *Q*... or should we?

OK. Answer is 'Death' if and only if determinant of given matrix is equal to 1 or - 1. Checking is techincal.

We have a minimal spanning tree on Euclidian plane, we should choose its DFS order to minimize sum of distances between neighboring points. Cool, sounds like we understand the statement, what's next? Not so fast.

Let's deal with small details first. What do we mean by 'choosing DFS order'? Isn't it fixed for tree? Well, no, because we can change the order of sons for every vertex. Distances in objective function measured on plane, not on tree.

We have a minimal spanning tree on Eucl... Wait. We don't have 'a tree', we have a minimal spanning tree. Minimal spanning tree of what? Well, of complete graph on these points. OK, cool, why do we need it? Isn't problem the same for all trees? Looks like it is true. And isn't it true that any tree can be spanning for some graph? For example, let's build a graph in which weight of an edge is a distance *on tree* between its endpoints. For sure our tree will be MST for this graph. What a stupid person wrote this statement!

Problemsetters. DO NOT. Write. Random things.

Strange things. ARE. Important.

Let's THINK. I know, I know, it is hard, and you already showed that problemsetter is stupid, it is time to write your almighty clarification to show who is boss. But for one second. Let's analyze all the things in this statement.

Yes, it is true that any tree can be MST for some graph. But can any graph be a graph with Euclidian metric? Not really. We should have triangle inequality... and we have it for our example. So problemsetter is still stupid? Not so fast. Euclidian plane is not just a metric, it is some fixed metric. And we have geometry. We can measure angles, for example.

Let's look at our MST. Take some vertex *v* and two its different neighbors *u* and *w*. What do we know? The distance between *u* and *w* should be the largest among these three vertices, otherwise it won't be MST. A greater angle of a triangle is opposite a greater side. Yeah, that useless theorem from school geometry. It says that angle between two edges from one vertex is at least π / 3. And strictly greater, if vertices are in integer points. From this we can conclude that degree of any vertex in our MST is not greater than 5.*That can't be true. For sure problemsetter would write this in statement if it was true. It is limitation on input, problemsetters are obliged to write these!* Oh really.

Probably there is more that you can extract from MST in Euclidian metric, but the fact about degrees is sufficient to solve a problem.

Well, only if you have some patterns of how you should solve problems. And you should have them, patterns are good, they're the fastest way to solve problems.

We have to choose radii for given centers in order to cover a circle with smaller circles. We want to minimize maximum of radii.

Oh, min max problem, I know what to do! Do binary search on answer, then check if circles with given radius cover big circle.

And it is correct solution, but it works in (intersect *n*^{2} pairs of circles and check all the intersections in *O*(*n*) time). It is geometry, operations are heavy, we can get TL.

Let's think about covering given point of big circle. What small circle will cover it? Of course the closest. So, we are interested in maximal distance between some point inside big circle and closest in given set of points. That's obviously a problem on Voronoi diagram. Now *O*(*n*^{3}) is very easy, is standard and is possible, probably only with library code :)

This observation costs medals for some teams on ICPC WF 2018. Our team also stuck with first model and didn't even try to code because implementation seems very heavy and we were sure that it will get TL. To be frank, also no one in our team could write Voronoi in , so it is not that important :)

Last example in this blog will be not from Timus, it is 2016 Yandex.Algorithm Round 3, Problem F, shout-out to Endagorion for creating such pearl.

Problems visible only to participants, so I'll give already simplified problem statement here:

Given a tree, all vertices are initially white. Two players, Red and Blue, take turns coloring white vertices (surprise) red and blue. The game ends when there are no white vertices left. The score of the game is *C*_{R} - *C*_{B}, where *C*_{R} is a number of connected components on red vertices, and *C*_{B} is a number of connected components on blue vertices. Red wants to maximize the score, Blue wants to minimize it. Find the score if both play optimally. *n* ≤ 2·10^{5}.

The statement is clear, but we don't like the formula. Especially we don't like *C*_{i}, because they change unpredictably. What can we say about connected components after deleting some vertices of a tree? Well, they are all trees themself. What we know about trees? Number of vertices is exactly 1 bigger than number of edges. OK, so number of components in a forest is exactly number of vertices minus number of edges. We can now rewrite the formula. *C*_{R} - *C*_{B} = (*V*_{R} - *E*_{R}) - (*V*_{B} - *E*_{B}) = *E*_{B} - *E*_{R} + (*V*_{R} - *V*_{B}). Value in brackets is constant, it is . So now we play not for components, but for edges. Better, but still not obvious.

We control vertices, can we somehow express *E*_{i} using only vertices? Do we have any equations expressing number of edges through vertices? Yes, we have. . But for calculating *E*_{R} we should sum only *deg*_{R}(*v*), the number of red neighbors. That's bad, but let's try anyways.

. Turns out this is true, because all RB-edges cancel out.

So, formula for score is

Now it is easy to see that each player should take vertex with smallest degree available at the moment.

CODEFESTIVAL site is updated with info about this year edition but only in Japanese.

Using Google Translate I read that this time only people living in Japan are allowed to participate (at least in the final round).

rng_58, can you confirm this?

Main reason for asking now is that the Finals date is 17.11 which is very close to TCO onsite dates (13.11-16.11).

I want to apologize once more for queue problems. It has also aggravated some tight ML/TL issues which probably would be not so big otherwise. I hope you enjoyed the problems nevertheless.

Tutorial is loading...

Tutorial is loading...

38799800 — logs

38799811 — case analisys

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

I hope that Petr is not mad at me for my joke.

Tutorial is loading...

38799850

38799853 — completely different solution with complexity *O*(6^{n / 2})

Tutorial is loading...

Tutorial is loading...

I hope that DarthPrince is not mad at me for my joke.

Tutorial is loading...

Tutorial of Codeforces Round #485 (Div. 1)

Tutorial of Codeforces Round #485 (Div. 1)

Tutorial of Codeforces Round #485 (Div. 2)

Tutorial of Codeforces Round #485 (Div. 2)

Hello!

I'm glad to invite you all to Round 485 which will take place on Tuesday, May 29 at 18:35 UTC+3.

There will be 6 problems in each division, 3 of them are shared between divisions. 2 of div.2 problems created by KAN, 7 others created by me. The contest duration is 2 hours. My problems were originally used in HSE Championship.

I would like to thank Merkurev and GlebsHP with whom I discussed the problems, I_love_Tanya_Romanova for testing, KAN for round coordination and Codeforces and Polygon team for these beautiful platforms. I would also like to thank HSE for organizing the event. Oh, and kb. for writing great legend for one of the problems (he will be surprised).

For those who for some reason like to know score distribution in advance:

div.2: 500 — 1000 — 1250 — 1750 — 2250 — 3000

div.1: 500 — 1000 — 1750 — 2500 — 2750 — 3000

But I didn't properly discuss it with KAN so this is subject to change :)

UPD: Discussed with KAN, scores for C and D in div.2 increased by 250.

Good fun, have problems, read all the luck. As usual.

Oh, and if there will be no bad things, round will be rated. I hope.

I'm very sorry for issues with queue. I understand that it could ruin the contest for many of you. But please be understanding. Bad things happen. It could be some network problems or some electricity problems. MikeMirzayanov, KAN and other people behind Codeforces trying their best to provide good service. But sometimes it's very hard for some reasons. I hope that you enjoyed the problems despite all the bad things.

We decided that round will be **rated**.

Editorial will be posted tomorrow.

div.1 winners:

1. tourist

2. OO0OOO00O0OOO0O00OOO0OO

3. Radewoosh

4. mcfx

5. LHiC

div.2 winners:

1. sminem

2. Fortza_Gabi_Tulba

3. cheburazshka

4. I_Love_KFC

5. CantGetAnyWaWhyImSoSmart

Editorial is up.

Announcement of Codeforces Round #485 (Div. 1)

Всем привет.

27 мая пройдёт личное первенство ВШЭ по спортивному программированию. К участию приглашаются (очевидно) студенты ВШЭ, а также школьники Москвы и Московской области, показавшие высокие результаты на региональном туре ВсОШ по информатике (500+ баллов, если у вас немного меньше, тоже можете подать заявку, если мы сможем вас разместить — разместим). Более подробную информацию можно прочитать здесь. Регистрация.

Задачки делаю я, другие плюшки — ФКН ВШЭ.

Ещё раз подчеркну — это **не** открытое первенство. Пожалуйста, не надо регистрироваться, если вы студент другого вуза :)

Дисклеймер и попытка ограничить количество участников: если ваш рейтинг ниже 1400, скорее всего вам будет весьма грустно на контесте.

На этих же задачах будет проведён Codeforces раунд 29 мая. Разумеется, о раунде будет ещё отдельное объявление :)

Когда-то давно я хотел сделать канал с какими-то мыслями по поводу задач с регулярных контестов

Сегодня я даже что-то сделал

Получилось стремно, на мой взгляд

Но я надеюсь, что

1. кто-то кроме меня тоже захочет что-то писать

2. формат постепенно трансформируется во что-то прикольное

В общем, приглашаются желающие рассказывать как они решают задачи, и желающие читать, как кто-то другой решает задачи.

К сожалению, RUS only. Я не готов писать так много на английском.

Ну и раз уж зашла речь: У меня есть более персональный канал, но там тоже почти все про ACM. Настолько почти все, что канал даже был признан блогом года по версии snarknews :)

I think that most of us know about situation with problem 843B - Интерактивный LowerBound. The intended solution (and it looks like all possible solutions) was randomized and it generates huge amount of hacks based on fixed randseeds.

I want to mention that I'm not against good randomized problems and I even set one myself.

But for me it seems that hacks can ruin such type of problems. The only thing author's solution is better than contestant's is that it is invisible during the competition. I can even imagine that some tester's solutions (maybe not the solution which is used to generate judge answers) was broken by some hacks.

I think that it breaks the problem as art piece and breaks the contest format too. You solved the problem just like authors wanted and now... it depends on is there a hacker in your room. It also breaks the idea of hacking. There is no bug in my solution, why should I be hacked? And why should the guy get 100 points for hacking me? He didn't crack my solution, he abused CF 'Run' tab.

And for me it looks like authors didn't think about that bug/feature and now they try to protect themselves in comments. For me it could be a good enough reason not to use this problem on CF round. This problem would be a good problem in ACM contest and I know that these guys do ACM contests. But maybe there were a way to prevent such abuse of hack system?

What about forbidding hacking this particular problem? It has two obvious flaws (maybe more).

1. After this post it can give a hint that you should use randomized solution — Yes, this is a problem.

2, All problems should be equal! You are taking away our sacred right to hack!!!1! — Are they? There are a lot of problems with no hacks on CF. There can be many reasons: the problem was too easy, or too hard, or it has no corner cases, or it can be solved only in one way, or, or... You can say that I propose unnatural way to prohibit hacking and in those cases it was prohibited by the problem itself. But (in my opinion) such randomized problem also naturally prohibits hacks because hacks can ruin the problem.

And it is also not true that all problems were 'equal' in this sense before. There were some problems with multitests which allow to hack with only one test in multitest. There can be a bug in handling multitesting but we cannot hack this bug.

This brings us to less cardinal solution: make some bounds on hacks. Like *n* ≤ 100 or (in this particular problem) let only choose values in list, but not their order.

Anyway, I think that problemsetters and coordinator should think about these matters in the future.

Я получил футболку с надписью "CODEFORCES THREADS 2017", но я не помню такого контеста.

С другой стороны, за Good bye 2016 обещали футболки.

Возможно, я не знаю какого-то перевода слова thread.

Так или иначе, MikeMirzayanov (или gKseni), можете рассказать, что это за футболка?)

Suppose we want to solve a problem by doing binary search on answer. Then the answer will be checked against jury's answer by absolute or relative error (one of them should be smaller then ε). For simplicity we will assume that our answer is always greater than 1 and smaller than *B*. Because of that, we will always use relative error rather than absolute.

Suppose we have made *n* iterations of our binary search — what information do we have now? I state that we know that real answer is lying in some segment [*x*_{i}, *x*_{i + 1}], where 1 = *x*_{0} < *x*_{1} < ... < *x*_{i} < ... < *x*_{2n} = *B*. And what is great — we can choose all *x*_{i} except for *x*_{0} and *x*_{2n}.

Now, for simplicity, we will also assume that we will answer *x*_{i + 1} for segment [*x*_{i}, *x*_{i + 1}] and the real answer was *x*_{i} — it is the worst case for us. It is obvious that we will not do that in real life, any other answer would be better, but you will get the idea.

So, what is our relative error? It is . Worst case for us is when relative error is maximal. It is logical to make them equal — exactly what we do by binary search with absolute errors. . We can assume that so . Now we have , but , so . How large should be *n* to get error less than ε? . Much smaller than .

How to write such binary search? We want to choose *m* in such a way that or simply .

Now I want to deal with some assumptions I made.

How to choose answer in the end? Again, (it is basically the same as dividing the segment in binary search).

What to do if the answer can be smaller than 1? Try 1; if answer is smaller than 1~--- use standard binary search (because absolute error smaller than relative); is answer is bigger than 1~--- use the binary search above.

P.S. I have never heard about this idea and come up with this while solving 744D - Hongcow Draws a Circle. I'm sorry if it is known for everyone except for me.

If you are registered on Timus, then you should have been received e-mail with invitation to this contest. The contest will be on 19 November in 11 Moscow time.

It was a junior championship but it was 'a little' harder than it was intended. As I remember, Merkurev solved all the problems with only 15 minutes to go, so I think that this contest may be interesting for participants with different levels, up to the strongest ACM teams.

The duration is 5 hours, standard ACM rules. It is a team (up to 3 participants) contest but you are welcome to partcipate individually too.

The authors of the problemset are Um_nik, Umqra, kb., Tinsane and dieglaube.

Hello!

October Clash on HackerEarth has started and you have 23 more hours to go.

I am the author of this problemset and niyaznigmatul is a tester. I want to thank Umqra who helped me a lot with preparation.

I hope you find the problems interesting and wish you good luck!

Q1: I'm a newbie. What should I do to become great coder?

A1: ~~Stop doing competetive programming~~ Solve problems.

Q2: I'm doing CP for two months and I'm still ~~not red~~ green. What should I do?

A2: ~~You are lazy and impatient~~ Solve more problems.

Q3: You became a red in less than two years, it is unbelievable!

A3: No, it isn't. ~~You can do it too if you will solve fucking problems.~~

Q4: You became a red blah-blah-blah such a huge fan blah-blah. Oh, and what should I do to become as great as you?

A4: ... right. You already know the answer. Solve problems. ~~I hate you.~~

Q5: I'm not good at DP [or something]. What can you suggest?

A5. Maybe you should try to ~~stop asking stupid questions and~~ solve some problems on DP? Or read some blogs and editorials.

Q6: I can't solve a problem / understand your code. Can you help me?

(Well, it is not a bad question in general. It is a good (if you really want me to explain something not to write the solution instead of you) question. But...)

A6: Sure. Can you provide the link to the problem / code?

(I'm not joking, it is a real story).

Bonus!

Q0: Hello bro/sir.

A0: Stop doing this please.

Access to the specified resource has been forbidden.

Codeforces said 20 minutes ago when I was trying to login. The same was about two weeks ago. In both cases I was unable to login for about 10 minutes.

And I constantly logout. Sometimes I can't read 3-4 blog posts before logout.

There were a post about logouting two or three days ago but I can't find it now because search is not working too.

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Nov/17/2019 01:47:01 (h3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|