awoo's blog

By awoo, history, 2 months ago, translation, In English

2203A - Towers of Boxes

Idea: BledDest

Tutorial
Solution (BledDest)

2203B - Beautiful Numbers

Idea: BledDest

Tutorial
Solution (Neon)

2203C - Test Generator

Idea: FelixArg

Tutorial
Solution (FelixArg)

2203D - Divisibility Game

Idea: FelixArg

Tutorial
Solution (FelixArg)

2203E - Probabilistic Card Game

Idea: BledDest

Tutorial
Solution 1 (awoo)
Solution 2 (awoo)

2203F - Binary Search with One Swap

Idea: BledDest

Tutorial
Solution (BledDest)
  • Vote: I like it
  • +23
  • Vote: I do not like it

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The time complexity on F is unexpected. Did anyone managed to fit $$$O(n\log(n))$$$?

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

Fun fact: for some reason my solution on D got TL with static arrays and OK with vector… Shouldn’t it be exactly the opposite thing?

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

    The problem was that in your static array version you used maxv=1e6+10, while in your vector code you used n+m+1, which is correct. So I'm guessing you got TL from out of bounds, which already happended to me some time.

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

      with maxv = 2e6+10, I still get TL...

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

        sort(all(backk)); backk.erase(unique(all(backk)), backk.end());

        The problem is that you're sorting back, but because of the harmonic sum back's size is O(N*logN), so sorting it is therefore O(N*log²N) which is too heavy for N=10^6 and 2 seconds.

        In your vector version, you just check from each number from 1 to n+m, which is way faster.

        Also you don't need this back array at all. If you use it only for cleaning it won't cause much damage, bush it will still be a heavy part although I guess not causing TL. I just recommend you cleaning all numbers from 1 to n+m in that case.

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

It is possible solve E with walking in the segment tree? or i'm hallucinating

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

    I thought about this during the contest and I believe it is possible

    • »
      »
      »
      2 months ago, hide # ^ |
       
      Vote: I like it +9 Vote: I do not like it

      It is! Look at this O(N*logN) submission: https://mirror.codeforces.com/contest/2203/submission/364393228. I basically replaced the "look for intersection point" logic with ternary search for the minimum point of the maximum value between the two functions, since you can easily proove unimodality. so when I'm at a non-leaf node at function query, I take a look at the value of the rightmost leaf in the left node and the leftmost leaf at the right node. To do this quickly I always store mn, mn2, mx and mx2 which represent the two farthest active leafs to the left and to the right respectively. It was 3x faster than my O(N*log²N) solution. To be honest I didn't expect much better because segment tree recursion is normally heavy, specially in this case with ternary search and a lot of parameters in the query function

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

I appreciate simple explanatory solution of C, Please continue to give the top notch explanation especially for C and D problems in the contest as that's the barrier of most of people. awoo

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

https://mirror.codeforces.com/contest/2203/submission/364592102

any idea why am I getting TLE on the 41th TC, in problem D

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

For problem C editorial, the a0 value is wrong, it should be 49 not 57

»
7 weeks ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

Fun fact: E can be solved in O(nlogn) because the point the edu is talking about always turns out to be the mean of the elements (because the sum of elements to its right is as close as possible to the sum of elements to its left) we check costl and costr of the element that is less than ceil(mean) (since the mean is not necessarily an integer) and check costl and costr for ceil(mean) https://mirror.codeforces.com/contest/2203/submission/364764786

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

D is a very beautiful problem. Thanks to problemsetters for a great contest.

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

For Problem C, as it is mentioned, the final array after moving the set bits to the correct positions, we get

[0,…,0,0,0,4,1,0,0,0,3]

Is it necessary to apply binary search? Cannot we move the bits forward as far as possible, and we will get the maximum ci?

As in the above example, we can move the last position 3 forward, but can move only even bits, so 1 will remainig and instead of 2, we will set 1 at the next position to the left and try to move it to the correct position? Won't this work

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

Not sure what is wrong its taking a hell lot of time for a simple s = 13 and m = 5 testcase. I have copied the editorial solution but in java. https://mirror.codeforces.com/contest/2203/submission/365255697

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

This C is more complicated than i thought it would be....