rotavirus's blog

By rotavirus, 5 years ago, In English

Hello! Codeforces Round 581 (Div. 2) will start on Aug/20/2019 17:35 (Moscow time). The round is rated for everyone whose rating isn't greater than 2099.

The problems were invented and prepared for you by rotavirus, rotavirus and rotavirus. Thanks to Anton arsijo Tsypko for the coordinating the round. Thanks to the testers for testing and giving advice:

You will be given 5 problems and 2 hours to solve them. The score distribution will be announced later is 500-750-1250-(1500+750)-2500.

The round is over! Congratulations to the winners:
1. 79brue
2. sinus_070
3. baluteshih
4. weishenme
5. shahaliali1382

An editorial.

  • Vote: I like it
  • +352
  • Vote: I do not like it

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

you forgot rotavirus

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

    to you he is mister master

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

      for uno i'm not

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

        Mr orange, I was your alt for half a year, and you didn't asked me to test your contest?

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

          Yes because why should i ask myself for testing my round dude

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

            since you didn't liked Twice we disbanded, so you are not my alt anymore!

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

Yout better say thanks to Mike MikeMirzayanov Mirzayanov for the amazing platforms Codeforces и Polygon if you want your round to be rated)))

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

All the best for your 1st contest :)

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

Bencil Sharpeniro orz

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

That army of 15 testers...

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

hello sorry_marymarine,

i am predicting this to be great contest,, because i know for facts that BencilSharpeniro is a very good problem testing man,

last time he giving me the problems, i felt like it was a good problems, so i having the faith in this contest and qualities of this contest,,,..,,..

good luck and high rating mr master, rajeshwar~~

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

    Of course. I can assure you that the grammar for problem A is on point. I ran it through Grammarly just for you bentaji <3.

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

      So, grammarly servers has the problems in its logs. Any grammarly devs here?

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

Good luck and high rating to all :)

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

I am so psyched.

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

Desire for becoming Candidate Master tonight!! :)

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

Thank you, "spsk spsk"

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

there is a problem with account link ? "The problems were invented and prepared for you by danilz1806, baumanec " both link to ur account

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

    He owns half of the master accounts on Codeforces

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

      Are you him?

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

        I refuse to give information to the penguin intelligence agency.

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

      but they share the same link with the same profile

      i mean when u press on "danilz1806" its gonna open "sorry_marymarine" profile

      sorry for bad english :|

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

        When you change handle, your old handle links to your account iirc.

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

Please fix long testing queue for pretests during contests. It's really annoying to wait for results during contest . Thanks

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

Questions made are excellent but I would suggest to improve the testing queues during submissions. I can understand it is a complex job to do given that many submissions are made in a single instant but if this fault is cleared, then people will be more motivated to take part in such thrilling contests. :)

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

I don't know how to tell you, because I'm only a pupil.

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

    Tiat is so cute! (Tiat is the girl in the picture)

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

I will become expert after the contest :))

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

Is it rated guys??

Coz, I know Nothing.

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

    It is only rated for women

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

      Can you PLEASE share your algorithm to identify female coders?

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

With such army of tester, I expect super strong pretest.

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

    quantity =/=> quality
    although, it's good to be optimistic.

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

    When I finished 2 Ds, I felt scary. But when I saw my comment here, no more fear.

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

Hoping to get the last point to be a Candidate Master!! :)

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

About 20 people trying to make a contest for us. How lucky we are. :D

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

15 peoples are tester for contest. <3 I thinks this round don't need hacking. I'm afraid =))))))

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

    I just solved some problems and gave some advice to make statements better, I didn't try to submit wrong or tricky solutions. Most of other testers too, I think.

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

For me you are Mr Master.

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

clashes with Mineski VS Na'Vi :(

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

why I can't get registered

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

Where is the link to ask a question? I think I rember that on every problem page there was such a link, but can not find it. :/ Is it gone? (Maybe caused by to much stupid questions ;)

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

BINARYFORCES!!!

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

The word "subsequnce" appears 7 times in the problem statement of D1 and D2

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

    haha

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

    How many time subsequence appear as a subsequence in the problem statement?

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

maybe I got it. my bad

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

Uh, why does solving D2 not auto solve D1? RIP penalty. ;_;

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

    When did it ever do that

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

      In my dreams and imaginations -- Pretty much what happens after one engages to work in the industry and cares about user experience. Kappa

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

What is test case 13 for C?

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

My score has plunged to 532

Calc Pro XD

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

I hope this is the first and last time i ever see 998244853 in a contest.

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

Does anyone know why I TLE on pretest 13 of prob. C. I'm pretty sure my algorithm runs in O(n^3 + m) worst case which should fit in the bounds.

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

Nice task E, thanks)

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

How to solve C ??

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

    I tried greedy, but I got WA on 5th. Never mind, I had a bug. It is a greed algorithm. O(n^3) (Floyd–Warshall) + O(m) linear search get we erase b in this scenario (a — b — c). If dist[a][c] == dist[a][b] + dist[b][c] then we can erase b, otherwise he stays in array.

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

      I was trying to figure out the condition which can be used to remove element from p(i). But found nothing. :(

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

        Condition to erase p[i] :

        There is a j and a k such that j<i<k and dist[p[j]][p[k]]=k-j . Dist[x][y] is the shortest path in the graph betwen x and y

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

    You can apply Greedy algorithm. For each triplet, ( left, current, right ), if you can go from left --> current and from current --> right ,but you can't directly go from left to right, then we can remove current. This ensures that the shortest path from left to right includes current. Hence, it retains the original sequence.

    You can use a stack to process every triplet.

    The time complexity is O(m + n*n).

    Code

    Edit --> It can't be solved without using Floyd Warshall

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

    You can make a Floyd-Warshall to calculate the APSP,then you just need to search the sequence (starting with the first number) the number that is farther away and that the difference in positions is the minimum path between those two, then you keep it and go to that one and repeat it until you reach the end,O(N*M)

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

I submited D1 without any testing or even compiling in last 30s an it passed, tests are probablu awful for this one.

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

Bonus for E. Solve it in $$$O(n)$$$

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

    I think problem E would be much easier if the constraints are set to fit $$$O(n)$$$, e.g. $$$n \leq 100000$$$, because one need not consider an $$$O(n^2)$$$ approach instead, which could simplify thinking.

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

Upd: Ignore, got it.
In div2E, did we have to use the fact that number of sequences whose maximal prefix sum is k is equal to product of catalan numbers($$$C_{x_{i}}$$$) such that sum of $$$x_{i}$$$ is n-k)?

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

E can be solved in O(n+m) 59161848

to solve this you need to calculate C(n, r) in O(n) preprocess and O(1) query

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

Maybe I should call this round...

UnsuccessfulSubmissionForces.

Problem A and C are really tricky.

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

Anybody want to explain D? The last example does not make sense to me.

0111001100111011101000

Answer should start with 000100... but the example says 001100...

Why? Which condition would not be satisfied if the answer starts with 000100...?

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

    Any subsequences, not only consecutive.

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

    Consider subsequence in [3,6]. The longest non-decreasing in input is 2, but your example is 3.

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

    In 001100 the longest non-decreasing subsequence is 4 In 000100 the longest non-decreasing subsequence is 5

    But in input string the longest non-decreasing subsequence s[1:6] = 4, not 5!

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

    You're considering sub-string(s) . For 't' we have to consider sub-sequences.

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

If you know Catalan number's formula's proof, you could solve E with complexity O(n)

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

    Can you explain it more clearly ? Thank you !

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

      You can read this and use the trick which is presented in proof. You can calculate : Number of array that has max-prefix greater or equal to x

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

    Do you have any other problems that use the same technique? :)

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

Nice problem D

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

    how to solve?

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

      We turn the array over, then we consider zeros and ones at each step and say, if zeros are less  or  equal then ones, then we put zero in a new line

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

        why would that work?

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

          because if the number of zero is smaller than the number of one than you turn this number(1) into 0 can effect the number of zero ,it adds 1.but the number of one doesn't change. UPD:and you didn't change the biggest

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

I am a new to hacking. Is hacking allowed only during the contest?

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

    In normal rounds yes, but in the extended ICPC rules you get 12 hours of open hacking after the contest ended.

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

Feels really great when you finish debugging C 40s after the contest ended :(

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

What about problem C? Is it Floyd–Warshall algorithm?

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

I don't understand problem C.

What " and p is one of the shortest paths passing through the vertexes v1, …, vk in that order." means?

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

    It means, that there is no strictly shorter path than p passing through all vertexes v1, ..., vk in that order.

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

      And i should find the shortest sequence of vertices that this path 'P' pass through?

      Whether yes or no, Could you explain more about what should the output be?

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

        Yes.

        Since $$$v$$$ is a subsequence of $$$p$$$, I will define another sequence, $$$a$$$, such that for all $$$i$$$ in range $$$[1, k]$$$ $$$p_{a_i} = v_i$$$ and $$$a$$$ is ascending.

        You should output a sequence $$$v_1, v_2, \ldots , v_k$$$ such that:

        • $$$v$$$ is of course a subsequence of $$$p$$$
        • $$$v_1 = p_1$$$, $$$v_k = p_m$$$
        • for all $$$i$$$ from $$$1$$$ to $$$k-1$$$ the length of shortest path between $$$v_i$$$ and $$$v_{i+1}$$$ is equal to $$$a_{i+1}-a_i$$$
        • there is no subsequence of length strictly lesser than $$$k$$$, for which above three conditions are all true

        For example in test

        4
        0110
        0010
        0001
        1000
        4
        1 2 3 4
        

        The proper answer is

        3
        1 2 4
        

        because:

        • it is a subsequence of $$$(1, 2, 3, 4)$$$
        • the first and the last elements of both sequences are equal
        • for all $$$i$$$ from $$$1$$$ to $$$k-1$$$ the length of shortest path between $$$v_i$$$ and $$$v_{i+1}$$$ is equal to $$$a_{i+1}-a_i$$$:
        1. shortest possible path from $$$1$$$ to $$$2$$$ has length 1
        2. shortest possible path from $$$2$$$ to $$$4$$$ has length 2
        • there is no subsequence of length $$$1$$$ or $$$2$$$ that satisfies all these three conditions
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

First competition so I have a few questions. - When do we get our rating? - How do you read the score distribution? I'd be grateful if anyone could answer.

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

    The ratings need like an hour or so, sometimes more.

    Score distribution? There is a link to "Standings".

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

Actually, the first problem was the hardest

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

    I would not say the hardest, although clearly harder than B for me

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

      I suppose the first two problems' placement could be swapped

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

who can tell me the thinking process about Pro.C,never solve the pro.c since came here

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

    And the meaning of "The main characters have been omitted to be short."

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

      That means "Let's skip the little useless story and go straight to the problem"

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

What's wrong with this solution? Problem A
1- Read the user input as a decimal value in a variable s
2- Output the round up value of log4(s)

for exemple 100000000 is 256 in base 10 and log4(256) is 4 because power(4,4) = 256
and 101 is 5 and the round up of log4(5) is 2 and so on ...

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

    With numbers up to 2^256 I think using that might be not precise enough.

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

      I think the logic is okay the problem is in my implementation I'm using C++ and I used a variable s as uint64_t so I can only store 64 bits so when the user input is more than 64 bits I got problems so I have to use a type where I can store 100 bits if someone know a type in C++ where I can store more than 100 bits please help

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

        string *_*

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

          I can't use string in log fonction xD

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

            you can... If you think about it the length of the string is very closely tied with the log2 value

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

        typedef __int128 lll;

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

Could someone help me figure out what is wrong in my logic in question C. 59182371

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

    I mean, they don't need to be adjacent to have a shortest path that goes around the 'inter' in your code.

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

    After experimenting with various test cases, I finally came up with one that your code fails on. I hope this will help you better in understanding where you went wrong

    4
    0101
    0010
    0001
    0000
    4
    1 2 3 4

    The expected answer is of length 3 , but your code outputs a sequence of length 2.

    Hint : Suppose we have a sequence (a,b,c,d). We take a into our path. We cannot reach c from a, hence we neglect b. Now, we cannot reach d from c, hence we also neglect c. This is where you went wrong. Since we've already deleted b, we should check the condition on the triplet (a,c,d).

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

15 testers and even the basic test cases are not covered for problem C. A simple path graph of length 5 is enough to hack a guy. Why were all the basic cases not covered?

http://codeforces.me/contest/1204/submission/59167944

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

    When testing, testers mostly gave feedback on the problems, not the tests. Also, all testers who solved C did so without running into this test case.

    And just because a single case wasn't covered doesn't mean all basic cases weren't covered. A lot of edge cases were covered, for example:

    2 0100 2 1 2

    System tests and hacks are a part of Codeforces, it's really hard to avoid and check every single case.

    Please be considerate of the authors for taking the time to put the round together and writing the problems. It's a shame this happened to many participants.

    Best of luck in the future.

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

    dude, the humans' idiotism, retardness and stupidity don't have limits.

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

      I can understand people posting weird-ass solutions which could pass sometimes, but there should have been a path graph test case in there somewhere.

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

    See the glass as half full: you have the opportunity to hack someone.

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

Will you provide the table of most hacks?

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

What was the intended solution for D?

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

what is the problem with s.size() and (ll)s.size()? s.size() gives wrong answer but (ll)s.size() gives correct answer.

With (ll)s.size() https://codeforces.me/contest/1204/submission/59182674

With s.size() https://codeforces.me/contest/1204/submission/59158562

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

    s.size() returns size_t type integer, where size_t is an unsigned integral data type. So, it can't be negative.

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

    s.size() has type size_t, if say size is 1 and you subtract 2 from it, it won't go to -1, it wraps around, see this : size_t in reverse for loop

    using ll ensures proper conversion. :)

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

      I face this problem many times in codeforces only. I don't face this problem in any other sites like codechef etc.

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

Why 1e8 operations doesn't fit to 2 sec in C, when 1e9 fit to 1 sec in Codeforces? Even when I make 1e7 for get WA I get TLE can anyone explain?

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

    shit I wrote

    for (int j = i - 1; j >= max(1, j - 100); j--) {
    

    instead

    for (int j = i - 1; j >= max(1, i - 100); j--) {
    

    get AC in 0.6 s

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

Test case 2 in problem C. I don't understand why not true??? May be Im wrong??? Help me. Thanks you so much <3

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

I am a newbie now. I want tips how to become a legendary grand newbie. Help is highly appreciated

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

I am confused in test case 3 of problem C. Why the solution of test case 3 in Problem C can't be 6 1 2 3 3 2 1. Even if 1 is deleted from the sequence , shortest path from 3 to 3 is of distance 2 only.

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

    In the problem statement it is clearly mentioned that — "Any two consecutive numbers should be distinct"

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

    Miss that adjacent elements on the array v must be different

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

That's rally quite strage, that this army of testers didn't crash my solution in D2 (I did it after the end of the contest), in the worst sitation I have O(n^2), but on max systemtest my solution got only 30 ms.

Sorry, for my poor english

https://codeforces.me/contest/1204/submission/59180412

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

    dude, the humans' idiotism, retardness and stupidity don't have limits. i can't foresee which bad solutions can you invent

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

      But you must

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

      **But I thing this test is rather simple max_test (10000*("110")+20000*("10")+10000*("100")) or many others where there arу many non-decreasing sub-segments in a minimal partition, that's not soo hard to constract this test

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

      If I were the author of the solution, I would be really offended by your comment.

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

    Most people in "army of testers" (at least me) just wanted to solve the round beforehand and didn't work on wrong solutions.

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

      I thought that one of the most important thing is to try to build good maxtest. It's not quastion for you, it's a quastion for organisator of testers' work. And there are some hacks of task C with really simple tests too(n=4 and m=4)!

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

what a smooth contest!

No announcement and also fast testing.

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

every thing about this contest is really good, but the best thing is rotavirus'comments on this post lol

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

I solved problem C in O(m) without using Floyd-Warshall and without computing shortest paths. Here is my code: 59178907

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

    I also applied a similar logic. Although it cleared all the test cases (still does), but there is a big flaw in the logic. After dry running it a couple of times, I came up with this test case which fails with your code.

    4
    0100
    0010
    0001
    0000
    4
    1 2 3 4

    This is a linear chain. The answer should be of length 2. But your code produces an answer of length 3. The test cases for this question are too weak.

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

Test #4 in problem D1 Why isn't 0001000100001000101000 the answer? Maybe I didn't get the problem right, but I don't see values of l and r which can fail the test.

I've even cheched it for every [l;r] in program.

//before
    for(short int l=0;l<s.length();l++)
        for(short int r=l;r<s.length();r++){
            short int loc=1,i=l+1,max=1;
            while(i<=r){
                if(s[i]>=s[i-1]) loc++;
                else {
                    if(loc>max) max=loc;
                    loc=1;
                }
                i++;
            }
            if(loc>max) max=loc;
            before[l][r]=max;
        }

//changing the string
    short int i=0;
    while(s[i]!='\0'){
        if(s[i+1]!='0' && s[i]=='1') s[i]='0';
        i++;
    }

//after
for(short int l=0;l<s.length();l++)
        for(short int r=l;r<s.length();r++){
            short int loc=1,i=l+1,max=1;
            while(i<=r){
                if(s[i]>=s[i-1]) loc++;
                else {
                    if(loc>max) max=loc;
                    loc=1;
                }
                i++;
            }
            if(loc>max) max=loc;
            if(before[l][r]!=max) printf("\n%hi %hi",l,r);
            else printf("\nok");
        }
  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    First 6 characters "011100" has a good subsequence of size at most 4 while "000100" has size 5

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

      Why is the size of second good subsequence is 5? How does it look? Isn't it "0001" for "000100"?

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

        "00000"

        it's a subsequence not a substring.

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

solution for problem D2. So fun =))

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

+262 good contest

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

    +8 rating next contest =)) good luck

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

Finally reached blue :)

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

E can be visualised as a path counting problem in an $$$n$$$ by $$$m$$$ grid. Where going up is +1 and right is -1. And can be solved in $$$O(n+m)$$$.

Let $$$F(i)$$$ be the number of paths from $$$(0, 0)$$$ to $$$(n, m)$$$ that satisfy each point $$$(x, y)$$$ in the path satisfies $$$x - y \leq i$$$.

Answer is summation of $$$(i . (F(i)-F(i-1)))$$$ for $$$i$$$ in $$$1$$$ to $$$n$$$.

$$$F(i)$$$ can be found by counting all the bad paths for $$$i$$$ and subract it from total paths $$$(C(m+n,m))$$$. A bad path is a path where there exists atleast one vertex that is of the form $$$(y+i, y)$$$, in other words, the path meets the line $$$x-y=i$$$. It can be seen that the bad paths, given $$$i$$$ have a bijection with paths from $$$(0,0)$$$ to $$$(m+i+1, n-i-1)$$$. (If we swap the number of up and right moves from the first point of intersection with $$$x-y=i$$$). Number of bad paths is $$$C(n+m, m+i+1)$$$.

So $$$F(i)$$$ is just $$$max(C(n+m,m)-C(n+m,m+i+1), 0)$$$

Also, feels good to be on the blog for the first time :)

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

C can't be solved without using Floyd Warshall (equivalently, BFS from all vertices)

Going through the solutions of problem C, I have observed a lot of people (including me), solve the question without using Floyd Warshall and deleting vertices in a greedy manner. Although the solution passes all the system test cases, I believe it is wrong.

People have used 2 approaches for greedily deleting the vertices.

Approach 1 :: Checking every window of size 3 without modifying the array.

This approach fails for this test case.

4
0101
0010
0001
0000
4
1 2 3 4

Expected 1 3 4
Output 1 4

Approach 2 :: Checking every window of size 3 (while actually deleting elements using stack).

This approach fails for this test case. 4
0100
0010
0001
0000
4
1 2 3 4

Expected 1 4
Output 1 2 4

rotavirus Can you add these test cases to the problem ?

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

    I fail in C because my bfs counts only one way from u to v (if v has other way) Today morning I fix it and get AC. I think that my solution also greedy.

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

      As I said, BFS from each vertex is essentially the same as Floyd Warshall. The time complexity of your code is O(n*m + n*n*n). My point is that you cannot lower that O(n^3) factor to O(n^2).

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

finally expert :)

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

When you want to troll ~12k contestant with 998244853 but almost no one got tricked

Spoiler

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

    I spent 30 minutes on this module number. I have wrote the code of E for 3 times. At first I use the math formula. It's right and the complexity is $$$O(n)$$$. At last I use $$$O(n^2)$$$ dp. I won't believe the module number any more. 555...

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

      Me too.And even worse,I spent 2h on this number without finding out it.

      Perhaps I am a fool:(

      I learnt a lesson,and it taught me a lot

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

Does anynoe use modulo 998244353 on problem E like me...

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

    I think you can't pass the fifth sample if you use 998244353... XD

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

      Yes.And I thought my solution is wrong until I found it.

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

        Your previous submissions don't even have modulo hardcoded. Did you type ...353 by memory? It is one of the things you should never do on contests. If something is written in the statement, copy it from there.

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

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

I am solving the problem c in o(n3 + m) time complexity still getting a tle Here is a link to my solution , can somebody please help me https://codeforces.me/contest/1204/submission/59177220

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

Please help me with this test case. ( Problem C)

4
0110
0001
0001
0000
3
1 2 4

The answer according to accepted code is

2-> 1 4

But if you draw the graph you can see that there is another road to go from '1' to '4' which is 1--3--4.

So why the answer is

2-> 1 4.

I think it may be 3-> 1 2 4.

Help me with proper logic of this test case.

Thanks in advance

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

    Important only that way from 1 to 4 shortest (not important how many ways exist).

    I think it means that you can't restore original way from correct solution and it not necessary.

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

    To prove, that this is correct answer for this problem, suppose, that there exists a correct answer of strictly lesser length than 2 (in this case we are only considering a subsequence of length 1).

    Of course a path of length 1 is incorrect for this test case, because (from the statement) the first and the last elements of path $$$p$$$ and its subsequence $$$v$$$ must be equal, so if path of length 1 would be correct, we would have $$$1 = p_1 = v_1 = v_k = p_m = 4$$$, so there is no correct answer of length strictly lesser than 2.

    We proved that the answer's length is at least 2, so now we can prove, that $$$v = (1, 4)$$$ is a correct answer:

    • $$$v$$$ is a subsequence of $$$p$$$
    • $$$v_1 = p_1 = 1$$$, $$$v_k = p_m = 4$$$
    • the shortest path between vertexes $$$v_1 = 1$$$ and $$$v_2 = 4$$$ has length 2

    As you can see $$$v = (1,4)$$$ satisfies all needed conditions, so it is a correct answer.

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

Why problem d was two parts? I think E Should be two parts

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

The system test of Problem C is too weak

I hacked about 15 solutions after the contest!

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

    sorry for this. i am rather unexperienced problemsetter and i can't foresee all the wrong solutions to invent the countertests

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

Hello! I think that the output for the fourth input of this problem D1 has mistake.

Because the longest non decreasing subsequence of output is 13, but the input is 12. If i made a mistake help me understand.

Sorry for my poor english.

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

    both have the same length of the longest nondecreasing subsequence. please don't say "the output is wrong" 2 weeks after a contest. it was carefully prepared, tested and then a lot of participants solved that problem.

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

Your round is one of the best rounds I have participated in. Thanks a lot