majk's blog

By majk, 6 years ago, In English

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:

  1. webmaster
  2. sunset
  3. tourist
  4. whzzt
  5. hos.lyric
  6. eatmore

UPDATE 4: Global Rounds 2019 final results

Announcement of Codeforces Global Round 6
  • Vote: I like it
  • +323
  • Vote: I do not like it

| Write comment?
»
6 years ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

I am always waiting for such a DIV1 + DIV2 round :)

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it +81 Vote: I do not like it

    Div2 ppl — Let's rank up above some div1 guys.
    Div1 ppl — Let's not get outperformed by some underdogs.

»
6 years ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

Hoping to see a colour change.

»
6 years ago, hide # |
 
Vote: I like it +52 Vote: I do not like it

Once upon a time there were instant editorials after the end of contests.

»
6 years ago, hide # |
 
Vote: I like it -86 Vote: I do not like it

Can some red coder suggest how a person (not very good at maths) can reach that level?

»
6 years ago, hide # |
Rev. 2  
Vote: I like it -27 Vote: I do not like it

 Me Everytime

»
6 years ago, hide # |
 
Vote: I like it +50 Vote: I do not like it

Anyone noticed the blog tag “Alice” and “Bob”?

»
6 years ago, hide # |
 
Vote: I like it -76 Vote: I do not like it

This round for disha :- my high school crush Hoping to get better rating

»
6 years ago, hide # |
Rev. 2  
Vote: I like it +19 Vote: I do not like it

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.

»
6 years ago, hide # |
Rev. 2  
Vote: I like it +2 Vote: I do not like it

So we have tourist and wxhtxdy both registered for the round, it will be fun stalking the standings page.

»
6 years ago, hide # |
Rev. 2  
Vote: I like it +36 Vote: I do not like it

»
6 years ago, hide # |
 
Vote: I like it -50 Vote: I do not like it

Why can't comments be sent in Chinese?

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it -14 Vote: I do not like it

    Oh shit goddamn grey Indians who love maths disliked my comment and made my contribution < 0

»
6 years ago, hide # |
 
Vote: I like it -13 Vote: I do not like it

hope to see dark blue in the profile today.

»
6 years ago, hide # |
 
Vote: I like it -10 Vote: I do not like it

Distribution ?

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Well done, majk did everything for after-contest.

    Then you'll be happy to hear that it is already written.

»
6 years ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

attending university classes makes my iq lower by 20 but I will try

»
6 years ago, hide # |
 
Vote: I like it +30 Vote: I do not like it

Speedforces!!

»
6 years ago, hide # |
 
Vote: I like it -27 Vote: I do not like it
The comment removed because of Codeforces rules violation
»
6 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

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.

»
6 years ago, hide # |
 
Vote: I like it +208 Vote: I do not like it

»
6 years ago, hide # |
 
Vote: I like it +21 Vote: I do not like it

E is easier than D...

  • »
    »
    6 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it -20 Vote: I do not like it

    Calculate the loss and profit of each person.

    Assign the money from the ones in loss to the ones in profit one by one.

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What is pretest 2 of B?

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve D?

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

god damn it I needed 2 more minutes to submit C

»
6 years ago, hide # |
Rev. 2  
Vote: I like it -12 Vote: I do not like it

nvm

»
6 years ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

Could you guys show me some hints for D? <3

  • »
    »
    6 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it +1 Vote: I do not like it

    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.

    • »
      »
      »
      6 years ago, hide # ^ |
      Rev. 2  
      Vote: I like it 0 Vote: I do not like it

      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://mirror.codeforces.com/contest/1266/submission/67138128

      • »
        »
        »
        »
        6 years ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        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.

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Problem D --> Splitwise Algorithm Was easily available on internet. This is sad lol.

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

50 minutes of debugging for a frickin number of line in output for problem D. at least i found out the mistake last sec.

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve B in cpp?

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it
    if (x < 15) 
    {
    cout << "NO\n";
    return 0;
    }
    x %= 14;
    if (1 <= x && x <= 6) cout << "YES\n";
    else cout << "NO\n"; 
    
»
6 years ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

Does anyone have a test case for problem E that will fail the basic solution?

  • »
    »
    6 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it +3 Vote: I do not like it

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

»
6 years ago, hide # |
 
Vote: I like it +75 Vote: I do not like it

Am I the only one who treated D as a graph problem and keep finding patterns?

»
6 years ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

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?

»
6 years ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

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.

»
6 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

How to solve D?

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

https://mirror.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

»
6 years ago, hide # |
 
Vote: I like it +37 Vote: I do not like it

Out of curiosity — how many people proved their solutions of D and E?

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it +5 Vote: I do not like it

    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.

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it +37 Vote: I do not like it

    I did, I guess that's why I'm so slow. :(

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it +10 Vote: I do not like it

    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.

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    I did

  • »
    »
    6 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    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

»
6 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

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 ~~~~~

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve C for r,c >= 2 ?

  • »
    »
    6 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    Well, consider two things :

    1. 1 can never appear in the square. (Why?)

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

    • »
      »
      »
      6 years ago, hide # ^ |
      Rev. 3  
      Vote: I like it 0 Vote: I do not like it

      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 array

      2)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 136

      I don't know why doesn't it work

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
»
6 years ago, hide # |
 
Vote: I like it +36 Vote: I do not like it

It was really difficult round :( Grandmaster for 3 days (P.S. D was quite interesting, though)

»
6 years ago, hide # |
 
Vote: I like it +29 Vote: I do not like it

Hello, dear majk, it seems to me that you would be good at doing olympiads for mathematicians!

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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 money

balance is positive : he must take money

every giver returning money to taker eliminates one giver or taker. no need to sort.

67119475

»
6 years ago, hide # |
Rev. 3  
Vote: I like it +56 Vote: I do not like it

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.

»
6 years ago, hide # |
 
Vote: I like it +21 Vote: I do not like it

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.

»
6 years ago, hide # |
 
Vote: I like it +110 Vote: I do not like it

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 ehnryx
71 1266 70 nuip
93 1266 93 tempura0224
127 1266 127 yhchang3
142 1266 142 schtamas
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 unnoticable_guy
482 1266 482 Superuzir
»
6 years ago, hide # |
 
Vote: I like it +66 Vote: I do not like it

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.

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it +27 Vote: I do not like it

    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.

»
6 years ago, hide # |
 
Vote: I like it -10 Vote: I do not like it

Div1+Div2 rounds are always fun to give <3

»
6 years ago, hide # |
 
Vote: I like it -6 Vote: I do not like it

1266B - Dice Tower teaches me that i need to read problem's statement carefully.

»
6 years ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

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 corner
»
6 years ago, hide # |
 
Vote: I like it -65 Vote: I do not like it

Why can't comments be sent in Chinese?

»
6 years ago, hide # |
 
Vote: I like it +22 Vote: I do not like it

congrats neal !!!

»
6 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

why my dp solution get Wrong answer for problem A.

here https://mirror.codeforces.com/contest/1266/submission/67097431