majk's blog

By majk, 5 weeks 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. stO
  2. sunset
  3. tourist
  4. whzzt
  5. hos.lyric
  6. abacabadabacaba

UPDATE 4: Global Rounds 2019 final results

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

»
5 weeks ago, # |
  Vote: I like it +6 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
      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.

»
5 weeks ago, # |
  Vote: I like it +14 Vote: I do not like it

Hoping to see a colour change.

»
5 weeks ago, # |
  Vote: I like it +52 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
    Rev. 2   Vote: I like it +300 Vote: I do not like it

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

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +89 Vote: I do not like it

      Can you share the links?

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it +271 Vote: I do not like it

        The SHA1 sum of the editorial to F is cc9919706a5a693e08430f184db20200b614dc00.

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it +98 Vote: I do not like it

          I hope that you'll upload more than just SHA1 sums after the contest.

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it +63 Vote: I do not like it

          He asked for a link. You should've posted something like this.

          • »
            »
            »
            »
            »
            »
            5 weeks ago, # ^ |
              Vote: I like it +69 Vote: I do not like it

            I don't know why I hovered to read the URL and THEN clicked.

            • »
              »
              »
              »
              »
              »
              »
              5 weeks ago, # ^ |
                Vote: I like it +76 Vote: I do not like it

              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.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +4 Vote: I do not like it

      thanks for the editorial!

      Im always waiting for it before and after the contest :)

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +22 Vote: I do not like it

    You know what is better? Editorial before the round happens.

»
5 weeks ago, # |
  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?

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it -8 Vote: I do not like it

    I_love_Tanya_Romanova had posted some great answers on Quora regarding that, you may wanna refer them :)

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it -9 Vote: I do not like it

      Can you please share the link of that answer?

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it +25 Vote: I do not like it

        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.

        1 2 3 4 5

        Hope it helps :)

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +25 Vote: I do not like it
  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    what a coincidence?

    You here asking how to be red and in problem set problem is based on same topic.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Maybe they have written the statement because of my comment :)

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it +2 Vote: I do not like it

        It was a coincidence, I came up with the story on Sunday, couple hours before your post.

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        And alsi problem are based on math because you have wirtten "not very good on math". :3

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it -21 Vote: I do not like it

          But d and e related to data structure and I love problem on data structure ❤❤

»
5 weeks ago, # |
Rev. 2   Vote: I like it -27 Vote: I do not like it

 Me Everytime

»
5 weeks ago, # |
  Vote: I like it +50 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    Sounds like there'll be game theory problems

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +32 Vote: I do not like it

      Sounds like majk always creates problems about them

»
5 weeks ago, # |
  Vote: I like it -76 Vote: I do not like it

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

»
5 weeks ago, # |
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.

»
5 weeks ago, # |
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.

»
5 weeks ago, # |
Rev. 2   Vote: I like it +36 Vote: I do not like it

»
5 weeks ago, # |
  Vote: I like it -50 Vote: I do not like it

Why can't comments be sent in Chinese?

  • »
    »
    5 weeks ago, # ^ |
      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

»
5 weeks ago, # |
  Vote: I like it -13 Vote: I do not like it

hope to see dark blue in the profile today.

»
5 weeks ago, # |
  Vote: I like it -10 Vote: I do not like it

Distribution ?

  • »
    »
    5 weeks ago, # ^ |
      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.

»
5 weeks ago, # |
  Vote: I like it +2 Vote: I do not like it

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

»
5 weeks ago, # |
  Vote: I like it +30 Vote: I do not like it

Speedforces!!

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it -18 Vote: I do not like it

    You forgot to include Mathforces XD

»
5 weeks ago, # |
  Vote: I like it -23 Vote: I do not like it

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!

»
5 weeks ago, # |
  Vote: I like it -27 Vote: I do not like it
The comment removed because of Codeforces rules violation
  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it -27 Vote: I do not like it
    The comment removed because of Codeforces rules violation
    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Комментарий удален по причине нарушения правил Codeforces

»
5 weeks ago, # |
  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.

»
5 weeks ago, # |
  Vote: I like it +208 Vote: I do not like it

»
5 weeks ago, # |
  Vote: I like it +21 Vote: I do not like it

E is easier than D...

  • »
    »
    5 weeks ago, # ^ |
    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.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

What is pretest 2 of B?

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    If the remainder of x%14 is zero the answer should be "NO".

  • »
    »
    5 weeks ago, # ^ |
    Rev. 2   Vote: I like it +4 Vote: I do not like it

    xi <= 6 && xi >= 1. For this case answer should be NO.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      You meant remainder wrt 14 right?.

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

        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.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve D?

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

god damn it I needed 2 more minutes to submit C

»
5 weeks ago, # |
Rev. 2   Vote: I like it -12 Vote: I do not like it

nvm

»
5 weeks ago, # |
  Vote: I like it +4 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
    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.

    • »
      »
      »
      5 weeks ago, # ^ |
      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://codeforces.com/contest/1266/submission/67138128

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          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.

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it +3 Vote: I do not like it

          Thanks I got it now

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Can you explain it further why there is no need of sorting? Thanks in advance

          • »
            »
            »
            »
            »
            »
            5 weeks ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            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?

            • »
              »
              »
              »
              »
              »
              »
              5 weeks ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              Yeah, I got the point.

              One more question:- If we want minimum number of transactions, we should go with sorting, right?

              Thanks

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Editorial is Out

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
5 weeks ago, # |
  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.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve B in cpp?

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
      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"; 
    
»
5 weeks ago, # |
  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?

  • »
    »
    5 weeks ago, # ^ |
    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...

»
5 weeks ago, # |
  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?

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    I related it to a graph and GCD problem...

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

    Me too, it could be simple greedy solution but made it mess by including graph theory

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Can you explain, how to solve it greedy please?

  • »
    »
    5 weeks ago, # ^ |
    Rev. 2   Vote: I like it +13 Vote: I do not like it

    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.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    me too i was trying to do something with weighted directed graphs . you are not the only one.

»
5 weeks ago, # |
  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?

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    Look at my comment above. Now I know I'm not the only one.

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

    Easily available on internet. "Splitwise algorithm" or "Minimize cash flow between friends".

»
5 weeks ago, # |
  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.

»
5 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

How to solve D?

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
5 weeks ago, # |
  Vote: I like it +37 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
      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.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +75 Vote: I do not like it

      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

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +53 Vote: I do not like it

      Out of curiosity — why did you think he was asking about the exact number?

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it -20 Vote: I do not like it

        he asked "how many". But even an approximation would be too hard to get, so his question is somewhat pointless.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +37 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
      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.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    I did

  • »
    »
    5 weeks ago, # ^ |
    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

»
5 weeks ago, # |
  Vote: I like it -26 Vote: I do not like it

wxhtxdy did not participate thinking tourist outperforms today but i guess tourist will stay at 1st position

»
5 weeks ago, # |
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 ~~~~~

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
    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

    • »
      »
      »
      5 weeks ago, # ^ |
      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

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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?

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it
        Construction and Thought Process
        • »
          »
          »
          »
          »
          4 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Thanks, I understand my mistake now

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it
»
5 weeks ago, # |
  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)

»
5 weeks ago, # |
  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!

»
5 weeks ago, # |
  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

»
5 weeks ago, # |
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.

»
5 weeks ago, # |
  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.

»
5 weeks ago, # |
  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 stO
2 1266 2 sunset
3 1266 3 tourist
4 1266 4 whzzt
5 1266 5 hos.lyric
6 1266 6 abacabadabacaba
7 1266 7 Um_nik
8 1266 8 neal
9 1266 9 zyb
10 1266 10 Endagorion
11 1266 11 aitch
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 kdh_9949
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 EtherLand
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 guestcheap
181 1266 181 sidhant
235 1266 235 Wild_Hamster
237 1266 237 jschr
284 1266 284 Stupid_G_u_y
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 VuaQT
482 1266 482 Superuzir
  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +43 Vote: I do not like it

    Thanks :)

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +11 Vote: I do not like it

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

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      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.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +34 Vote: I do not like it

      Our team will contact you. Just wait.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Nice Questions!!!

»
5 weeks ago, # |
  Vote: I like it +66 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
      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.

»
5 weeks ago, # |
  Vote: I like it -10 Vote: I do not like it

Div1+Div2 rounds are always fun to give <3

»
5 weeks ago, # |
  Vote: I like it -6 Vote: I do not like it

1266B - Башня из кубиков teaches me that i need to read problem's statement carefully.

»
5 weeks ago, # |
  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
»
5 weeks ago, # |
  Vote: I like it -65 Vote: I do not like it

Why can't comments be sent in Chinese?

»
5 weeks ago, # |
  Vote: I like it +22 Vote: I do not like it

congrats neal !!!

»
5 weeks ago, # |
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://codeforces.com/contest/1266/submission/67097431