### majk's blog

By majk, 16 months ago,

Hi!

Are you tired after a weekend of three (3) contests? Or are you ready for another one? On Dec/17/2019 18:05 (Moscow time) we will host Codeforces Global Round 6!

It is the sixth round of a new series of Codeforces Global Rounds supported by XTX Markets. The rounds are open for everybody, the rating will be updated for everybody.

You will be given 8 problems and 150 minutes to solve them. The scoring distribution will be 500-750-1250-1750-2000-2500-3500-4000.

The prizes for this round:

• 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 2019 (current results):

• In each round top-100 participants get points according to the table.
• 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 the whole series get sweatshirts and place certificates.

The problems of this round were developed by me. I will be available on Discord to discuss the problems after the contest.

I would like to thank:

UPDATE: The round is over! I hope you enjoyed it despite the second half being more difficult than anticipated. The system test will begin shortly.

UPDATE 2: Editorial

UPDATE 3: Congratulations to winners:

UPDATE 4: Global Rounds 2019 final results

Announcement of Codeforces Global Round 6

• +323

 » 16 months ago, # |   +6 I am always waiting for such a DIV1 + DIV2 round :)
•  » » 16 months ago, # ^ |   +81 Div2 ppl — Let's rank up above some div1 guys.Div1 ppl — Let's not get outperformed by some underdogs.
•  » » » 16 months ago, # ^ |   +35 (Few days after reaching Div. 1 xD)
•  » » » » 16 months ago, # ^ |   +63 More like, "Few days after reaching (Div. 1 + Div. 2)/2 xD".
 » 16 months ago, # |   +14 Hoping to see a colour change.
•  » » 16 months ago, # ^ |   +37
•  » » » 16 months ago, # ^ |   +11 Hopefully not this one .
•  » » » 16 months ago, # ^ |   0 how you changed colour?
•  » » » » 16 months ago, # ^ |   0 I bursted into laughing when I read this reply.How have you been on Codeforces for 18 months ad still have no idea how he changed colors.
•  » » » » » 16 months ago, # ^ |   0 ¬_¬
•  » » » » » 16 months ago, # ^ |   0 If you are so clever — why don't you change your own color. And I don't mean tricks with HTML markups. :P
 » 16 months ago, # |   +52 Once upon a time there were instant editorials after the end of contests.
•  » » 16 months ago, # ^ | ← Rev. 2 →   +300 Then you'll be happy to hear that it is already written.
•  » » » 16 months ago, # ^ |   +89 Can you share the links?
•  » » » » 16 months ago, # ^ |   +271 The SHA1 sum of the editorial to F is cc9919706a5a693e08430f184db20200b614dc00.
•  » » » » » 16 months ago, # ^ |   +98 I hope that you'll upload more than just SHA1 sums after the contest.
•  » » » » » 16 months ago, # ^ |   +63 He asked for a link. You should've posted something like this.
•  » » » » » » 16 months ago, # ^ |   +69 I don't know why I hovered to read the URL and THEN clicked.
•  » » » » » » » 16 months ago, # ^ |   +76 Preemptively reading what you're clicking at is survival instinct. Clicking anyway is poor survival instinct. In retrospect, I could've added .onion at the end.
•  » » » » » » » » 16 months ago, # ^ |   0
•  » » » 16 months ago, # ^ |   +4 thanks for the editorial!Im always waiting for it before and after the contest :)
•  » » 16 months ago, # ^ |   +22 You know what is better? Editorial before the round happens.
•  » » » 16 months ago, # ^ | ← Rev. 2 →   +18
 » 16 months ago, # |   -86 Can some red coder suggest how a person (not very good at maths) can reach that level?
•  » » 16 months ago, # ^ |   -8 I_love_Tanya_Romanova had posted some great answers on Quora regarding that, you may wanna refer them :)
•  » » » 16 months ago, # ^ |   -9 Can you please share the link of that answer?
•  » » » » 16 months ago, # ^ |   +25 Well he has posted a lot of answers, here are some of those and although I don't really follow him but some of my friends do, and have really seen nice improvements.Hope it helps :)
•  » » » » » 16 months ago, # ^ |   0 Nightmare05 now I know why you were asking....
•  » » 16 months ago, # ^ |   +25
•  » » 16 months ago, # ^ |   +8 what a coincidence? You here asking how to be red and in problem set problem is based on same topic.
•  » » » 16 months ago, # ^ |   0 Maybe they have written the statement because of my comment :)
•  » » » » 16 months ago, # ^ |   +2 It was a coincidence, I came up with the story on Sunday, couple hours before your post.
•  » » » » 16 months ago, # ^ |   0 And alsi problem are based on math because you have wirtten "not very good on math". :3
•  » » » » » 16 months ago, # ^ |   -21 But d and e related to data structure and I love problem on data structure ❤❤
•  » » » » » » 14 months ago, # ^ | ← Rev. 2 →   -8 d
 » 16 months ago, # | ← Rev. 2 →   -27 Me Everytime
•  » » 16 months ago, # ^ |   +59 I always make strong pretests. Also, I never seen this Codeforces Round #470 (rated, Div. 1, based on VK Cup 2018 Round 1) before, officer.
•  » » » 16 months ago, # ^ |   -23 Kheili strong bood koskesh kioooni
•  » » » » 16 months ago, # ^ |   -17 |:
•  » » » 16 months ago, # ^ |   -20 Alan test 11 soal E pashm ame mane?
 » 16 months ago, # |   +50 Anyone noticed the blog tag “Alice” and “Bob”?
•  » » 16 months ago, # ^ |   +4 Sounds like there'll be game theory problems
•  » » » 16 months ago, # ^ |   +32 Sounds like majk always creates problems about them
 » 16 months ago, # |   -76 This round for disha :- my high school crush Hoping to get better rating
 » 16 months ago, # | ← Rev. 2 →   +19 Missed 2 of them because of my final exams. Tomorrow I have my finals in algorithm design. This time, to skip this contest would be to not study. Therefore I must do the contest, of course, only because I want to study.
 » 16 months ago, # | ← Rev. 2 →   +2 So we have tourist and wxhtxdy both registered for the round, it will be fun stalking the standings page.
 » 16 months ago, # | ← Rev. 2 →   +36
 » 16 months ago, # |   -50 Why can't comments be sent in Chinese？
•  » » 16 months ago, # ^ |   -14 Oh shit goddamn grey Indians who love maths disliked my comment and made my contribution < 0
•  » » » 16 months ago, # ^ |   -10 lol XP
•  » » » 16 months ago, # ^ |   -10 If an Indian becomes red should he be called a Native American?
•  » » » » 16 months ago, # ^ | ← Rev. 2 →   0 Oh shit goddamn grey Indians who love maths have no sense of humor!
 » 16 months ago, # |   -13 hope to see dark blue in the profile today.
•  » » 16 months ago, # ^ |   +9 disagree
•  » » » 16 months ago, # ^ |   +26 not in your profile brother
•  » » » » 16 months ago, # ^ |   0 yep, i am just king of humor
•  » » » » » 16 months ago, # ^ |   +18 disagree
•  » » 16 months ago, # ^ |   -7 Hope that I will get rank in 3 digits.
 » 16 months ago, # |   -10 Distribution ?
•  » » 16 months ago, # ^ |   0 Well done, majk did everything for after-contest. Then you'll be happy to hear that it is already written.
 » 16 months ago, # |   +2 attending university classes makes my iq lower by 20 but I will try
•  » » 16 months ago, # ^ |   -8
 » 16 months ago, # |   +30 Speedforces!!
•  » » 16 months ago, # ^ |   -18 You forgot to include Mathforces XD
 » 16 months ago, # |   -23 Thanks for such an awesome round! My weakest topic is Math that is why I am happy to face Mathforces. I demand more rounds like this!
 » 16 months ago, # |   -27 The comment removed because of Codeforces rules violation
•  » » 16 months ago, # ^ |   -27 The comment removed because of Codeforces rules violation
•  » » » 16 months ago, # ^ |   0 Комментарий удален по причине нарушения правил Codeforces
 » 16 months ago, # |   +3 What was the solution to problem E, although I got a AC, I still feel that a lot of solutions will fail systest including mine.
 » 16 months ago, # |   +208
 » 16 months ago, # |   +21 E is easier than D...
•  » » 16 months ago, # ^ | ← Rev. 2 →   -20 Calculate the loss and profit of each person.Assign the money from the ones in loss to the ones in profit one by one.
 » 16 months ago, # |   0 What is pretest 2 of B?
•  » » 16 months ago, # ^ |   0 If the remainder of x%14 is zero the answer should be "NO".
•  » » » 16 months ago, # ^ |   0 I found my bug, thank you all the same
•  » » 16 months ago, # ^ | ← Rev. 2 →   +4 xi <= 6 && xi >= 1. For this case answer should be NO.
•  » » » 16 months ago, # ^ |   0 You meant remainder wrt 14 right?.
•  » » » » 16 months ago, # ^ |   +6 Actually I was talking about specific case when xi is straight between 1 to 6 (not after modulo). In that case my initial code was giving YES, but the actual answer is NO. And that is what I think is the second pretest.
 » 16 months ago, # |   0 How to solve D?
•  » » 16 months ago, # ^ |   +3 Look up Splitwise
 » 16 months ago, # |   0 god damn it I needed 2 more minutes to submit C
 » 16 months ago, # | ← Rev. 2 →   -12 nvm
 » 16 months ago, # |   +4 Could you guys show me some hints for D? <3
•  » » 16 months ago, # ^ | ← Rev. 2 →   +1 Calculate the loss and profit of every person. Now you have an array with positive and negative numbers. Store them in two separate vectors 'take' & 'give'.Assign the money from the vectors 'give' to 'take' element by element greedily.
•  » » » 16 months ago, # ^ | ← Rev. 2 →   0 My attempt for 1266D - Decreasing Debts is similar to yours, but I had one question.I'm sorting the vectors of givers and takers by their amount , but i noticed that my solution gets accepted even if i don't sort them.Isn't it a necessary condition to sort the vectors?https://codeforces.com/contest/1266/submission/67138128
•  » » » » 16 months ago, # ^ |   0 It isn't necessary. The idea is if A has to give x to B and B has to give x to C. If not simplified, this 'x' is counted twice. After simplifying , it yields , A -> C 'x'. The issue here was that B who overall, does not want the money is being given the money and money is being taken from B. But, since in the two arrays you have formed , you are only creating transactions that will never be nullified by some other transaction, all transactions are valid. Sorting is therefore unnecessary.
•  » » » » » 16 months ago, # ^ |   +3 Thanks I got it now
•  » » » » » 16 months ago, # ^ |   0 Can you explain it further why there is no need of sorting? Thanks in advance
•  » » » » » » 16 months ago, # ^ |   0 A simple case to think can be, suppose A has to give 10 to B. C has to give 5 to D.How does sorting help?
•  » » » » » » » 16 months ago, # ^ |   0 Yeah, I got the point.One more question:- If we want minimum number of transactions, we should go with sorting, right?Thanks
•  » » 16 months ago, # ^ |   0 Editorial is Out
 » 16 months ago, # |   0 Problem D --> Splitwise Algorithm Was easily available on internet. This is sad lol.
 » 16 months ago, # |   0 50 minutes of debugging for a frickin number of line in output for problem D. at least i found out the mistake last sec.
 » 16 months ago, # |   0 How to solve B in cpp?
•  » » 16 months ago, # ^ |   0 The minimum possible number you can make is 15 and if the remainder of the given number X when divided by 14 is >=1 and <=6 then the answer is "YES" else "NO".
•  » » 16 months ago, # ^ |   +1 if (x < 15) { cout << "NO\n"; return 0; } x %= 14; if (1 <= x && x <= 6) cout << "YES\n"; else cout << "NO\n"; 
 » 16 months ago, # |   +11 Does anyone have a test case for problem E that will fail the basic solution?
•  » » 16 months ago, # ^ | ← Rev. 2 →   +3 The reason for so many fails on test case 11 is the handling of the order of events. If you kept track of number of bonuses to a resource, there is a possibility of adding and subtracting the same resource in a single query i.e., a bonus (a,b,c) just ends up replacing the exact same. Only if I had swapped 2 lines...
 » 16 months ago, # |   +75 Am I the only one who treated D as a graph problem and keep finding patterns?
•  » » 16 months ago, # ^ |   +8 I related it to a graph and GCD problem...
•  » » 16 months ago, # ^ |   +6 Me too, it could be simple greedy solution but made it mess by including graph theory
•  » » » 16 months ago, # ^ |   0 Can you explain, how to solve it greedy please?
•  » » 16 months ago, # ^ | ← Rev. 2 →   +13 Yup, tried solutions involving moving all children to a parent node (Not even going to start with how I was trying to make it a DAG to root it in the first place) and all sorts of other absurd stuff treating it as a graph problem.
•  » » 16 months ago, # ^ |   +1 me too i was trying to do something with weighted directed graphs . you are not the only one.
 » 16 months ago, # |   +7 Can someone explain me how to solve D with realisation moments. I've got, that if we have edges like a -> b; b -> c, we can make them a -> c and remove a -> b and b -> c.But how to code it?
•  » » 16 months ago, # ^ |   +8 Look at my comment above. Now I know I'm not the only one.
•  » » 16 months ago, # ^ |   +6 Easily available on internet. "Splitwise algorithm" or "Minimize cash flow between friends".
 » 16 months ago, # |   +2 I am so unlucky problem C i solved in last minute when i was submitting my solution 10 sec was left but unfortunately i failed. Feeling unhappy.
 » 16 months ago, # |   +1 How to solve D?
 » 16 months ago, # |   0 https://codeforces.com/contest/1266/submission/67110424 Can someone tell at what test case my code is failing for D. I tried many, all succeeded, but it gives WA in pretest 5
 » 16 months ago, # |   +37 Out of curiosity — how many people proved their solutions of D and E?
•  » » 16 months ago, # ^ |   +5 out of curiosity — how do you expect someone to answer the exact number of how many people proved?Also IMO problem D is easily proved, but E is indeed the type of problem that many participants submit the correct solution without proper proof.
•  » » » 16 months ago, # ^ |   +75 out of curiosity — how do you expect someone to answer the exact number of how many people proved? You know what the fuck I mean :D
•  » » » 16 months ago, # ^ |   +53 Out of curiosity — why did you think he was asking about the exact number?
•  » » » » 16 months ago, # ^ |   -20 he asked "how many". But even an approximation would be too hard to get, so his question is somewhat pointless.
•  » » 16 months ago, # ^ |   +37 I did, I guess that's why I'm so slow. :(
•  » » 16 months ago, # ^ |   +10 I had a proof outline of E in my mind, just that if we produce the obvious minima, there's always a reached bonus because equal sums and proof by contradiction, and if we imagine that this reached bonus isn't a bonus but a normally produced resource, the same idea applies by induction. At that point, I told myself that I have nothing to lose by believing I didn't miss something important.D is just obvious. We have the minimum required cash flow and we can send this flow any way we want.
•  » » 16 months ago, # ^ |   +1 I did
•  » » 16 months ago, # ^ | ← Rev. 2 →   0 I couldn't prove D or E , I was just lucky that my solutions passed as I had no concrete proof. Had any one failed, I would have no idea what to do. Though, D was close to a proof, in the sense that if some subset of people is losing some amount and others are gaining that much(in terms of net amount) then that amount of edges must be there and it turns out we can attain that lower bound precisely, making it the best
•  » » » 16 months ago, # ^ |   0 Come on Whatsapp if u r interested in proofs
 » 16 months ago, # |   -26 Retired_MiFaFaOvO did not participate thinking tourist outperforms today but i guess tourist will stay at 1st position
 » 16 months ago, # | ← Rev. 2 →   0 Are the tests weak for E or this testcase isn't possible? ~~~~~ 3 1 1 1 3 1 1 2 2 1 3 3 1 1 ~~~~~
•  » » 16 months ago, # ^ |   +13 You can't get awards for reaching the goals.
•  » » » 16 months ago, # ^ |   0 Ow, Tnx
 » 16 months ago, # |   0 How to solve C for r,c >= 2 ?
•  » » 16 months ago, # ^ | ← Rev. 2 →   0 Well, consider two things : 1 can never appear in the square. (Why?) A row which makes gcd as 1, can be multiplied by x to get a gcd of x. Now think of some numbers which make gcd 1 :), and you're almost done
•  » » » 16 months ago, # ^ | ← Rev. 3 →   0 Thanks.1) if we take 1 , then it will make gcd in 1 row and 1 col as 1, so we will have 2 ones in our b array2)about that I thought , may be I will do like this for ex. for 4 9 2 3 5 7 9 11 13 15 17 4 12 20 28 36 44 52 60 68 6 18 30 42 54 66 78 90 102 8 24 40 56 72 88 104 120 136I don't know why doesn't it work
•  » » » » 16 months ago, # ^ |   0 Well, how about choosing consecutive numbers rather than all odds and one 2? Maybe since you're skipping out some even numbers, if you could have just chosen them also, you might have gotten a lower answer?
•  » » » » 16 months ago, # ^ |   0 Construction and Thought Process
•  » » » » » 16 months ago, # ^ |   0 Thanks, I understand my mistake now
 » 16 months ago, # |   0 This is N^2 but same logic can be easily implemented in nlogn
•  » » 16 months ago, # ^ |   0 https://codeforces.com/gym/100812 problem A
 » 16 months ago, # |   +36 It was really difficult round :( Grandmaster for 3 days (P.S. D was quite interesting, though)
 » 16 months ago, # |   +29 Hello, dear majk, it seems to me that you would be good at doing olympiads for mathematicians!
•  » » 16 months ago, # ^ |   -52 And not for programmers...
•  » » 16 months ago, # ^ |   -47 Oh shit goddamn grey Indians who love maths disliked my comment and made my contribution < 0
•  » » » 16 months ago, # ^ |   +18 The ability to speak does not make you intelligent.
•  » » » 16 months ago, # ^ | ← Rev. 2 →   +11 I did it from 10 fake accounts.
 » 16 months ago, # |   0 PROBLEM D: just find out balance for each person: for each line of input: input u, v ,d balance[u] -=d balance[v] +=d balance is negative : he must give moneybalance is positive : he must take moneyevery giver returning money to taker eliminates one giver or taker. no need to sort.67119475
 » 16 months ago, # | ← Rev. 3 →   +56 Greedy $\mathcal{O}(m^2)$ solution for D passed the system tests but failed to this test: 100000 99999 1 2 1 2 3 2 3 4 3 4 5 4 5 6 5 . . . 99999 100000 99999 This is sad because I have similar solution which got TL5.
 » 16 months ago, # |   +21 D is neat because it both is a real life problem and can be solved with a real life approach.E is however weird. It just feels like you just do what it tells you to do.
»
16 months ago, # |
+110

Hi everyone, here is the list of T-shirt winners!

List place Contest Rank Name
1 1266 1 webmaster
2 1266 2 sunset
3 1266 3 tourist
4 1266 4 whzzt
5 1266 5 hos.lyric
6 1266 6 eatmore
7 1266 7 Um_nik
8 1266 8 neal
9 1266 9 zyb
10 1266 10 Endagorion
11 1266 11 _h_
12 1266 12 300iq
13 1266 13 Petr
14 1266 14 Amoo_Safar
15 1266 15 maroonrk
16 1266 16 betrue12
17 1266 17 ainta
18 1266 18 ecnerwala
19 1266 19 KAN
20 1266 20 kdh9949
21 1266 21 Kostroma
22 1266 22 aid
23 1266 23 Maksim1744
24 1266 24 gamegame
25 1266 25 receed
26 1266 26 amethyst0
27 1266 27 icecuber
28 1266 28 BigBag
29 1266 29 snuke
30 1266 30 PedyD
33 1266 33 LJC00118
57 1266 57 paulll
71 1266 70 nuip
93 1266 93 tempura0224
127 1266 127 yhchang3
142 1266 142 schtomi97
168 1266 168 sarkar
181 1266 181 sidhant
235 1266 235 Wild_Hamster
237 1266 237 jschr
284 1266 284 Flying_streaky_pork
314 1266 314 aryanc403
325 1266 325 Deemo
344 1266 343 jiwansandhu
391 1266 391 qx4ever
420 1266 419 tubone
427 1266 427 Lgq_3de5
453 1266 453 peterr
461 1266 461 EmperorQT
482 1266 482 Superuzir
•  » » 16 months ago, # ^ |   +43 Thanks :)
•  » » 16 months ago, # ^ |   +11 It's me!!!! This is sth I never thought!!! You can't even image how excited I'm!!! Right now!!!Because I have never won a prize in cf before, so I want to knwo how can I get it?? thanks a lot!!
•  » » » 16 months ago, # ^ |   +8 It's me too, I think i can imagine how excited you are because this is the first time i won a prize in codeforces, too. I have the same question as you: how can i get it.
•  » » » 16 months ago, # ^ |   +34 Our team will contact you. Just wait.
•  » » » » 11 months ago, # ^ |   0 Any news? Can't wait to get my first CF t-shirt :)
•  » » » » » 11 months ago, # ^ |   +3 No worries, you will get it very soon!
 » 16 months ago, # |   0 Nice Questions!!!
 » 16 months ago, # |   +66 eatmore, can you explain your approach on H? It's different from my solution, and I only managed to hack it via massaging the stress test.
•  » » 16 months ago, # ^ |   +27 My solution is using simulation with memoization. I don't know its time complexity. My implementation can probably be optimized, but I didn't have time to do it during the contest.It works like this: there is a map, where the key is the current vertex and the current state of some set of vertices. The set is such that, starting from the current state, the token will enter each vertex in the set at least once before entering a vertex that is not in the set. The value is the vertex that is reached and the new state.This approach should work really well on structured graphs, like red edge from $i$ to $1$ and blue edge from $i$ to $i+1$ for all $i$.I think that my solution can be adapted to solve your bonus problem as well.
 » 16 months ago, # |   -10 Div1+Div2 rounds are always fun to give <3
•  » » 16 months ago, # ^ |   0 yeah!!! these sure are fun :)
 » 16 months ago, # |   -6 1266B - Dice Tower teaches me that i need to read problem's statement carefully.
 » 16 months ago, # |   +14 If someone wants to feel some pain.My Solution to E in the contest at the very last minute Submission.Later, when I found the bug. Submission Goes in the cornerweeps :(
 » 16 months ago, # |   -65 Why can't comments be sent in Chinese？
•  » » 16 months ago, # ^ |   +32 because it's codeforces and not 程式设计forces
•  » » » 16 months ago, # ^ |   -22 The reason is not enough
•  » » » » 16 months ago, # ^ | ← Rev. 2 →   -22 MikeMirzayanov, he/she needs a reason.
•  » » » 16 months ago, # ^ |   +15 Lol, it's definitely not Кодforces ether.
 » 16 months ago, # |   +22 congrats neal !!!
•  » » 16 months ago, # ^ |   +30 Thanks! Finally made it.
 » 16 months ago, # | ← Rev. 2 →   0 why my dp solution get Wrong answer for problem A.