Скоро Codeforces Round 1133 (Div. 1, Div. 2)! Регистрация здесь. ×

Блог пользователя awoo

Автор awoo, история, 8 месяцев назад, По-русски

2203A - Башни из коробок

Идея: BledDest

Разбор
Решение (BledDest)

2203B - Красивые числа

Идея: BledDest

Разбор
Решение (Neon)

2203C - Генератор тестов

Идея: FelixArg

Разбор
Решение (FelixArg)

2203D - Игра в делимость

Идея: FelixArg

Разбор
Решение (FelixArg)

2203E - Вероятностная карточная игра

Идея: BledDest

Разбор
Решение 1 (awoo)
Решение 2 (awoo)

2203F - Бинарный поиск с одним обменом

Идея: BledDest

Разбор
Решение (BledDest)
  • Проголосовать: нравится
  • +23
  • Проголосовать: не нравится

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
8 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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?

  • »
    »
    8 месяцев назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    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.

    • »
      »
      »
      8 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

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

      • »
        »
        »
        »
        8 месяцев назад, скрыть # ^ |
         
        Проголосовать: нравится +1 Проголосовать: не нравится

        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.

»
8 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +2 Проголосовать: не нравится

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

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For E sqrt dec it is written Overall complexity: sqrt(m). Is it typo?

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

https://codeforces.me/contest/2203/submission/364592102

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

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

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://codeforces.me/contest/2203/submission/364764786

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Quite interesting C: when do binary search, we only know the fact that if we can satisfy with n, then n + 1 is also satisfied. But given fixed n, I think of how we ensure that follow the algorithm (go from most significant bit to least significant bit) will ensure a valid solution. Suppose n satisfied with a valid distributions of bit position where m set. Then if then we can always try to transfer lower bit to larger bit as much as when can and the valid state is not changed, this is exactly the same with the algorithm. ~~~~~ bool check(ll cnt, ll s, ll m) { for (int i = BIT — 1; i >= 0; i--) if ((m>>i) & 1) { s -= min(cnt, s / (1ll << i)) * (1ll << i); } return s == 0; } ~~~~~

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

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

»
8 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For Problem D, in solution it is mentioned that when alice is selecting value y from array b, then array a should be of its divisor only. but according to problem statment, least count of divisor should be one. am I not getting problem statement correctly?

»
8 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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://codeforces.me/contest/2203/submission/365255697

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
3 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

The given solution for C is amazing! Thank you for the tutorials!