ch_egor's blog

By ch_egor, 5 years ago, translation, In English

Hi everybody,

This Tuesday there will be a Moscow programming competition for school students of grades from 6 to 9. This contest is prepared by Moscow Olympiad Scientific Committee that you may know by Moscow Open Olympiad, Moscow Team Olympiad and Metropolises Olympiad (rounds 327, 342, 345, 376, 401, 433, 441, 466, 469, 507, 516, 541, 545, 567, 583, 594, 622, 626, 657, 680).

Round will be held at Feb/23/2021 12:05 (Moscow time). You will be given 5 problems and 2 hours to solve them. Round will be rated for second division (rating below 2100). As usual, participants from the first division can participate in a contest out of competition.

Problems are prepared by grphil, Jatana, rip, Sehnsucht, DebNatkh, KiKoS, wrg0ababd, V--o_o--V, voidmax, meshanya, vintage_Vlad_Makeev under my supervision.

Thanks to adedalic for the round coordination, cdkrot and meshanya for statement translation, and also thanks for MikeMirzayanov for systems Codeforces and Polygon, which was used to prepare problems of this olympiad.

Also thanks to Noam527 for providing an additional problem that helped to create (I hope) a balanced problem set for the round.

Good luck everybody!

Due to the official competition source codes of other participants will not be available for an hour after the end of the round.

UPD1: Thanks to LHiC, awoo, ScarletS, adarsh7777, kassutta, raj_mehta_ for testing.

UPD2:

Scoring distribution: 500 — 1000 — 1500 — 2250 — 3000

UPD3: Editorial

UPD4: Winners!

Div. 2:

  1. InternetPerson10
  2. egor95123657
  3. hhhyyyfff
  4. xXx_KevinDu58_xXx
  5. Flying2021

Div. 1 + Div. 2:

  1. Um_nik
  2. qazswedx2
  3. 3.141592653
  4. BigBag
  5. InternetPerson10
  • Vote: I like it
  • +62
  • Vote: I do not like it

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

thanks for this round.

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

The competition announcement should include a link to the competition: Codeforces Round 704 (Div. 2)

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

I am curious: why do all these contests prepared by Moscow Olympiad Committee have unusual timing?

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

Will the problem score distribution be announced for this round (since there is an official competition as well)?

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

I believe it will be a wonderful round!

Hope all of us can get good scores!

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

Notice the Unsual Timing.

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

For me living in China ,the timing is so good.

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

As a Chinese coder, I'm surprised to find out it's a good time for me to participate in the contest, normally for join the contest in Codeforces, I have to stay up late.

I'm looking forward to solving the problems, it'll be another chance for me to challange and improve myself. Stay Cheeki Breeki!

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

ok sorry for that.

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

Note: Unusual time

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

Unusual timing = less competition

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

One of my friends is interested in setting up a round. Does anyone know typically how much time it takes for the entire process (proposal of the round to the hosting of round)?

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

Hoping to get scoring distribution as early as possible

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

You guys(Russian school kids) do train hard regularly.. Nice going .. Hope to see similar things in my country too.

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

I sense chaos

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

I am curious: why do all these contests prepared by Moscow Olympiad Committee have unusual timing?

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

Even though we have quit our music career, we will continue to give contests on Codeforces.

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

Please share score distribution too

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

It hurts...

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

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

hope green delta for all

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

This timing is so much better for me. Afternoons are usually slow, this can give a nice touch. All the best to all.

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

I hope my rank and rating will be increase in this contest :)

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

I missed the time :(

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

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

Is C DP or greedy?

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

    answer is just lastoccurence[t[i+1]]-firstoccurence[t[i]] . but find occurence as if you take this s[i] there is one beautiful sequence. see my code for find first and last occurence :(

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

      except lastoccurence[t[i+1]] depends on the lastoccurence[t[i+2]] so you need to technically check the last occurence that does end up in a valid subsequence

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

      I also did the same but WA on test 5

      108271134

      Can you please help me what I did wrong ??

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

      it is not, consider testcase

      5 3
      aaaaa
      aaa
      

      ans==3, but your simple formular gives 4

      A more correct solution find the leftmost possible subeq of t[] in s[], and the rightmost one. Then ans is the max of the diff in all positions in left and right.

      Edit: Changed to reflect that ans==3, not 2.

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

      it's $$$max(postfix[m-i]-prefix[i])$$$ where $$$postfix[i]=$$$ largest index $$$j$$$ s.t. $$$s[j..n]$$$ contains $$$t[i..n]$$$ as a subsequence. and $$$prefix[i]= $$$least index $$$j$$$ s.t. $$$s[1..j]$$$ contains $$$t[1,,i]$$$ as a subsequence.

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

How to solve D ? :(

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

    I think maximum $$$k$$$ is obtained for something like $$$a = 11111000$$$, $$$b = 10111001$$$. I may be wrong. But this seems to work. We can then shift bits in $$$b$$$ to get all smaller values.

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

    we can get k ones if we subtract 2^0 from 2^k.

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

    first observe it, 1 -> 1 and 0 -> 0 results in 0, only you can use 0 -> 1 or 1 ->0 to have one.

    secondly, if you form a pattern like this -> 111000 011001 from this pattern you can have (one + zero -1) number of 1 as k. Now think a bit more about it. Hope you'll find the answer.

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

      if you can't still find the answer then think of it,

      10
      01
      

      if you put same bit inside those like this,

      111000
      011001
      

      then all of them will contribute in the answer except the first one. Now try rest by yourself.

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

How to solve E?

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

What was famous hack in problem D?

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

Can Anyone tell me pretest 18 of the D of this contest

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

Hacks,hacks everywhere!!!

Case 1
Case 2
»
5 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Editorial!!!!!!

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

Almost missed this round. UNUSUAL TIMING (: Started 5 minutes late with the fastest heartbeat ever.

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

Can anyone help. Why this solution is wrong import java.util.*;

public class A {

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    StringBuilder sb = new StringBuilder();
    int testCases = sc.nextInt();

    for (int t = 0; t < testCases; t++) {
        double p = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        long ans = Long.MAX_VALUE;

        long temp = (long) Math.ceil(p / a);

        ans = Math.min(ans, (long) (temp * a - p));

        temp = (long) Math.ceil(p / b);

        ans = Math.min(ans, (long) (temp * b - p));

        temp = (long) Math.ceil(p / c);

        ans = Math.min(ans, (long) (temp * c - p));

        sb.append(ans).append("\n");

    }

    System.out.print(sb);
}

}

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

    Calculating with large values and floating-point numbers gets imprecise, so for example the ceil might not give the correct value. Example

    Use integer ceil instead:

    ceil(a / (double)b) =
    (a - 1) / b + 1
    
»
5 years ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

I tried to hack A with 99999999999999998 2 2 2 but got an invalid hack error

Validator 'validator.exe' returns exit code 3 [FAIL Expected int32, but "99999999999999998" found (stdin, line 1)]

even though, the problem clearly says p < 1e18

Someone from the authors, please clarify this?

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

Can anyone explain why my submission for E 108288547 have WA on pretest 27?

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

how to do B i'm getting tle

edit: can we do it using bitset i've got the logic but not able to implement if someone has done it using bits please do share ur code

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

How sad it is when I got the observation for D so early but kept getting WA at pretest 8 around 1 hour and half :((

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

just now: hackforce

soon: FSTforce

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

Why is everyone discussing solutions and hacks... The contest for the kids is still going on in Russia.. Let's just control our curiosity for an hour

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

Due to the official competition source codes of other participants will not be available for an hour after the end of the round.

So maybe we shouldn't discuss anything about the contest especially the solutions and the hacks.

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

Felt more of like a Div 2.5 contest. It was great !!!

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

Thanks for the "strong" pretest of problem D!

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

In C .. why does the logic of setting max,min for each index (keeping in mind the neighbouring char's max,min index) fails on pretest 5. You can check my submission : https://mirror.codeforces.com/submissions/indresh_0903 Can anyone please help :/

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

    Submission viewing is off for an hour ,as official contest is still going on

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

    Notice the condition : $$$1≤p_1 \lt p_2 \lt … \lt p_m≤n$$$ .

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

      Yeah it was taken into consideration while calculating possible max and min index for each t[i] .. for each index .. its max is < max of i+1 (with base condition of t[m-1] )and its min > min i-1 (with base condition of t[0]) if for a particular 'i' its min and i+1's max will give me the ans, then for all index >i+1 .. there max-es will be used

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

        max and min doesn't guarantee the right sequence.

        for example,

        4 3
        aaba
        aab
        
        • »
          »
          »
          »
          »
          5 years ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          im getting 1 as answer for this tc i guess its correct

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

            It might work out for you. But, there would be some testcase where you calculated the difference of two illegal indices (i.e. these indices might not form a beautiful sequence) and set it as max.

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

              Dude i have set max of index i strictly smaller than max of i+1 and min of index i strictly greater than min of i-1 .. so i dont think that would be an issue

»
5 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it
from math import ceil
 
t=int(input())
for _ in range(t):
    p,a,b,c=map(int,input().split())
    print(min(ceil(p/a)*a-p,ceil(p/b)*b-p,ceil(p/c)*c-p))

Why is this wrong for A?

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

Guys did anyone else have this problem? When I sent a solution it said that I had already sent that solution but I was sending it first time. I did anything possible but it always said that I had already sent that solution.

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

Was D having a simple idea to trigger 1s in result starting from a pattern like

1 1 1 0 0 0

0 1 1 0 0 1.

Triggering flood of ones from right at 0,1 pair and stopping at 1,0 pair.

I didn't participated but just pondering over the idea.

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

    That is.

    Also, you can only produce 1s in that way since you have to use the same amount of 0s and 1s in x and y.

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

    well i too thought of this idea first , then i came to know that leading zeroes are not allowed in string x and y

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

This gives me RE on pretest 5

RE

whereas this gets AC on pretest

AC

I have changed only this much part of the code and nothing else. Someone please help me out in debugging the error.

UPD: I got the mistake I was doing. Thank you all.

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

@Admin/@MikeMirzaynov, if a person participates in a contest, why is it that that person is not allowed to make another submission until the system testing concludes? (Obviously I'm not asking you to count submissions after contest gets over) It has happened very often that I don't get a problem within the contest time bounds but do have a solution immediately after the contest gets over — and I have to wait for a while before my submission can be evaluated (because system testing is running) — Its bad enough that I wasn't able to solve it within the bounds, worse still that I can't check if my code is right or not when I finish it. Request you to look into it if possible...

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

    The answer is pretty obvious if you think, they want all their server power to be focussed upon system testing, so that they can be finished as fast as possible with the limited server power that they have.. The eagerness to know our solution's verdict has to be sacrificed a bit for this.. Tough world xD

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

Why was there sudden change in timings ? My midsems are approaching and had to miss 2 classes, nevermind tho, the contest was worth it. Sincere request to not change timings, old timings were perfect.

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

How to solve C using dp?

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

Is there any solution for E using graphs??

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

Thanks for the round though the pretests are a bit too weak...

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

good contest

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

Is this round "FSTForces" ?

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

Fst forces

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

Poor pretest for D :(

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

codefst

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

Believe it or not, I believe that today's round is just for hackers...(At least D)

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

Some very weak pretests for D (:

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

I want to know who makes problem D's data?

At least 400 coders failed system tests on this problem :)

(include me).

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

Thanks for the strong pretests! Love pretest producer!

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

Is this submission for A hackable? He used ceil and float when numbers are as big as 1e18. I got cases which fail in g++14 and couldn't find a hack case since he submitted in g++17

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

qwq oh noooooooooooo!thanks for pretest!!!

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

Good Guy! case for a=0 not in the pretest. Fst so many people.

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

Nobody:
Codeforces even after the systest: You're contestant.

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

Why I am not able to submit my code after system testing is over?

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

This Round is quite hard for me. QwQ

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

WHAT GOOD PRETESTS!!!!!!!! :(

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

Love this pretest. Expert time uwu

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

Corner cases should be included to the pretests...!!!

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

Maybe the pretests of D are too weak...

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

Maybe you should enhance the pretests carefully next time, otherwise people like me would be so sad to see their ratings fall...

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

I think the pretests of Problem D are too WEAK, many possible datas are IGNORED.

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

We're still unable to make any submissions post-contest. I believe, usually, we're allowed to submit immediately following the completion of system testing. Is there a reason that we still can't make submissions? I imagine there's a few people waiting to make corrected submissions following the large number of system test fails.

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

May be there should be some rule like if 30% pretest passed submissions failed main tests, round becomes unrated.

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

    Nah, official solutions are often tested very carefully to ensure that there is nothing wrong with them, especially when a problem is prepared for a major city-wide contest. If your solution fails system tests, it's safe to assume that it is wrong. Of course it can be the case that the official solution is wrong, but this has rarely happened in the past.

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

thanks for this round.

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

To not keep you waiting, the ratings updated preliminarily. In a few hours, I will remove cheaters and update the ratings again!

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

Thanks for this round.

But the pretests are a bit weak, and the problems are a bit easier than other Div.2? And I think five problems aren't enough for two hours. There are too many people solved out all the problems (even in the first hour) but failed on the system tests.

Hope there will be a better contest.

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

Why can't I hack solutions anymore? The button is gone although it didn't pass 7 days.

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

ll n, m; cin >> n >> m; string a, b; cin >> a >> b; vians; ll mx = -1e9; f(i, 0, m — 1) { char p = b[i]; char q = b[i + 1]; ll pos1 = a.find(b[i]); ll pos2 = a.find_last_of(b[i + 1]); ans.pb((pos2 — (pos1))); amax(mx, ans[i]); } // if (ans.size() > 0) { // ll anss = *max_element(all(ans)); // print(anss); // } print(mx);

can anyone tell what i am missing here? like i am finding left occurance of i and right occourance of i+1,,and taking max of them.

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

I don't want to raise any negativity but submissions from LiM_256 and sawa855 are suspiciously similar. They can be found at number 614 and 617 in final "official" standings. Seems like, they tried to alter some code to get away. Obviously, I'm not mentioning them.

Spoiler

PS: I apologize if I bring out something incorrect.

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

Hi, In problem A my solution was giving wa but I am not able to find reason for that. after that i changed my code, it got accepted. I am providing links of both , if anyone knows about this do reply. Accepted Wrong Answer

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

    I am not sure but when i used both of your code for test case : 1 1000000000000000000 3 3 3 The "Accepted" one is giving -64 and "Wrong Answer" one 0 as answer, i think its most probably because of overflow or something like that, the correct answer should be 2 for this test case.

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

    I think it's because ceil does not return an integer, which leads to floating precision issues. As mentioned many times above, try not to rely on ceil.