Автор awoo, история, 2 года назад, По-русски

Привет, Codeforces!

В 18.12.2021 18:35 (Московское время) состоится Educational Codeforces Round 119 (рейтинговый для Div. 2). Пожалуйста, обратите внимание на необычное время старта.

Продолжается серия образовательных раундов в рамках инициативы Harbour.Space University! Подробности о сотрудничестве Harbour.Space University и Codeforces можно прочитать в посте.

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Вам будет предложено 6 или 7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Задачи вместе со мной придумывали и готовили Адилбек adedalic Далабаев, Владимир vovuh Петров, Иван BledDest Андросов, Максим Neon Мещеряков и Роман Roms Глазов. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

Удачи в раунде! Успешных решений!

Также от наших друзей и партнёров из Harbour.Space есть сообщение для вас:

Codeforces and Harbour.Space

Привет, Codeforces!

Почти 5 месяцев прошло с тех пор как мы организовали Harbour.Space Scholarship Contest 2021-2022. Это был довольно сложный вызов для более чем 15 000 человек, принявших участие в раунде. Однако мы смогли отобрать тех, кто был готов воспользоваться возможностью и присоединиться к Harbour.Space в этом году. Помимо этого мы внимательно рассмотрели все заявки на стипендии и наградили в общей сложности 11 студентов.

Мы хотели бы представить вам наших обладателей стипендии, которые уже прибыли в Барселону:

aniervs, MaksymOboznyi, 244mhq, Meijer, bthero,amanbol, DimmyT, 998kover

Мы с нетерпением ожидаем достижения невероятных высот нашими новыми командами ICPC. Одна из них, Harbour.Backspace (MaksymOboznyi, 244mhq, 998kover), уже занял З-е место в Moscow Workshops. Желаем им всего наилучшего во всех предстоящих раундах.

Codeforces and Harbour.Space

Как и всегда мы будем очень рады видеть участников сообщества Codeforces как наших студентов здесь в Harbour.Space.

UPD: Разбор опубликован

  • Проголосовать: нравится
  • +206
  • Проголосовать: не нравится

»
2 года назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

Excited for the contest, Wishing everyone high ratings in last Educational Round of 2021.

»
2 года назад, # |
  Проголосовать: нравится -18 Проголосовать: не нравится

forward Kazakhstan

»
2 года назад, # |
  Проголосовать: нравится +28 Проголосовать: не нравится

Always love educational round.

»
2 года назад, # |
  Проголосовать: нравится +70 Проголосовать: не нравится

Please, note the unusual start time.
ok at this point I got lost, what's the actual usual time!?

»
2 года назад, # |
  Проголосовать: нравится -20 Проголосовать: не нравится

unusual unusual time(you know,usual unusual time means before 17:35)

»
2 года назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

The start time in China is too unusual!

»
2 года назад, # |
Rev. 2   Проголосовать: нравится +21 Проголосовать: не нравится

Shouldn't it be BYE BYE educational 2021 XD...

»
2 года назад, # |
  Проголосовать: нравится -76 Проголосовать: не нравится

cheaters who registered in this round: nitin_05 ashokesen02

  1. will they cheat again in this round?
  2. if so, will they not be caught and be rated again?!
  3. who will cheat better and drain more ratings from other innocent users?!?
  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +21 Проголосовать: не нравится

    Why you just keep on posting same thing again and again in every contest's announcement.My advice to you is not to focus on others whether they are cheating or not rather you should practice more and more to surpass those cheaters. And for cheaters they can become expert or CM by cheating but ratings without having knowledge is of no use they can't use it anywhere be it in Online tests,interviews.

    So just focus on developing skill and you can see positive outcomes after sometime :D.

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

SIUUU

»
2 года назад, # |
  Проголосовать: нравится -22 Проголосовать: не нравится

Wasn't this time the usual one now it became unusual

»
2 года назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

Why so negative?

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

I hope this round will be excellent! (as usual <3)

»
2 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Hope this time my rating will increase and my contribution rating will not go more negative.

»
2 года назад, # |
  Проголосовать: нравится -26 Проголосовать: не нравится

C should not exist

»
2 года назад, # |
  Проголосовать: нравится +19 Проголосовать: не нравится

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

I m not able to understand the 3rd test case of the C problem we can at max replace all '*' with 'bbb' and then also the rank will be 16 but it is asking for 20? Help me understand it. Be merciful on me.

  • »
    »
    2 года назад, # ^ |
    Rev. 4   Проголосовать: нравится +6 Проголосовать: не нравится

    If I am not wrong for the third test case of C 6 3 20 **a*** output -- babbbbbbbbb The strings are --

    - a
    - ab
    - abb
    - abbb
    - abbbb
    - abbbbb
    - abbbbbb
    - abbbbbbb
    - abbbbbbbb
    - abbbbbbbbb
    - ba
    - bab
    - babb
    - babbb
    - babbbb
    - babbbbb
    - babbbbbb
    - babbbbbbb
    - babbbbbbbb
    - babbbbbbbbb
    

    btw was not able to solve it.. RIP

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +9 Проголосовать: не нравится

    The number of possibilities is not 16. In the first group of asterisks, we can have at most 6 'b'. In the second group of asterisks, we can have at most 9 'b'. So, the total number of possibilities is (6 + 1) * (9 + 1) = 70.

    You can fix the first group of asterisks with some number of 'b'. Then, you can have 10 different strings as you can adjust the number of 'b' in the second group of asterisks.

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

C is in a difference lever :v

»
2 года назад, # |
  Проголосовать: нравится +21 Проголосовать: не нравится
Back at it again :')
»
2 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Please any one give me a hint to solve E ??

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

    linked list

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +13 Проголосовать: не нравится

    its actually just basic implementation [too easy for position E, I think].

    For each query of type-1, find the nearest to the right query of type 2 which has the same $$$x$$$ and add an edge between these two indices. For each query of type 2, find the nearest to the right query of type 2 which has $$$x$$$ as the $$$y$$$ of current query and add an edge.

    this structure forms a forest.

    Then the value of each type 1 query in the final array is just the value of the root of the tree this index is a part of.

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +4 Проголосовать: не нравится

    Try to build array by performing actions given in input in reverse order and store some useful information.

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +6 Проголосовать: не нравится

    You can store for each x, all indices that have value equal to x in a vector, let's call it v[x].

    For the queries: set all elements equal to x to y, you can move all the elements from v[x] to v[y], use small to large to do this.

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

      So it will be O(n^(3/2))?

      • »
        »
        »
        »
        2 года назад, # ^ |
          Проголосовать: нравится +3 Проголосовать: не нравится

        No, it will be $$$O(N\cdot\log{N})$$$, each time you merge two vectors, the resulting vector will be at least two times the size of the small vector, so each element will be moved from a vector to another at most $$$\log{N}$$$ times.

        Note that you swap the vectors if needed to move always from the smaller to the bigger, just using swap is $$$O(1)$$$ for most stl containers, like vectors, sets, maps.

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

          Wow, interesting, thanks. And in this problem we could kinda do it in O(n) using deque instead of vectors, right? Since merge of deque is O(1).

          • »
            »
            »
            »
            »
            »
            2 года назад, # ^ |
            Rev. 3   Проголосовать: нравится +6 Проголосовать: не нравится

            Are you sure that deque's merge is O(1)? cppreference doesn't mention it, and considering how deques work, I think it is complicated to do it in O(1), I am not sure tough.

            With a conventional double linked list you can do that, but I think deques are something more complex.

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

              Crap, I thought deque in c++ IS a conventional double linked list. Thanks for pointing out. Now I need to go and check if deque id double-LL at list in my python... :)

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +19 Проголосовать: не нравится

    I think simplest solution is to iterate the queryies from last to first. We maintain a transision table, no tree or something complecated needed.

    see 139792544

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

    My solution uses array of linked lists.

    For query of the form 1 x, we add index of x (which is equal to current number of appended elements so far) to the end of the linked list located at array[x].
    For query of the form 2 x y we move all elements of the linked list located at array[x] to array[y].

    At any given point, array[val] stores all the original indices which ended up holding the value of val. https://codeforces.com/contest/1620/submission/139814623

  • »
    »
    2 года назад, # ^ |
    Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

    If you execute the operations from the last going backwards you can keep&update a mapping for each number quite easily. At the start, mapping[x] = x for every x. Then:

    • type 1, append mapping[x] to the result
    • type 2, update mapping[x] = mapping[y]

    then print reversed(result)

»
2 года назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

I didn't have time but I think problem G can be solved using inclusion-exclusion for each mask of subsequence [where the value of each mask represents the number of strings which are subsequences of all strings which have bit set in the mask]. Is it the right idea?

»
2 года назад, # |
  Проголосовать: нравится +17 Проголосовать: не нравится

Can E be solved with some modification to dsu?

  • »
    »
    2 года назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится
    Spoiler
»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can I improve my delta by hacking someone else's solution?

»
2 года назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

I eagerly wait to know the author of problem D

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

I didn't get AC for B until there was exactly 1 minute left because I used int instead of long

»
2 года назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится
  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    The attempt was so blatant lol, Dude commented the block of code and then wrote the same code and thought that he wouldn't be caught by the CF plag system.

    The first thing any plag tool does is to wipe off all the comments, spaces and indents and read the code as one single line.

    How dumb can one be.

»
2 года назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

Was I the only one who found E much easier than both C and D.

»
2 года назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

12 wrong submissoins on C. I just want to die

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

My approach for Problem E: Replace the Numbers

The idea is pretty similar to 365A: Knight Tournament

Suppose an element $$$x$$$ is appended to the end of the array at the $$$j^{th}$$$ query. We can make the following 2 observations:

  1. The final value of this element would not depend on any Type-1 or Type-2 query strictly to the left of the $$$j^{th}$$$ query.
  2. If we have two Type-2 queries strictly to the right of the $$$j^{th}$$$ query, say at indices $$$k_1$$$ and $$$k_2$$$, (such that $$$k_1 < k_2$$$), and they both operate on $$$x$$$, i.e they both instruct to change the value of $$$x$$$ to $$$y$$$ or $$$z$$$ respectively, then the first query takes precedence.

So, if we process the queries in reverse order, then by the time we reached the $$$j^{th}$$$ query (counting from zero), we would have all the information to restore the value of $$$x$$$, if we keep overwriting the values of $$$x$$$ in case of overlapping Type-2 queries.

So, if we define $$$sink[x]$$$ as the value that $$$x$$$ should be currently converted to, we can process the queries as follows:

  • Type-1 Queries: Just append $$$sink[x]$$$ to the result.
  • Type-2 Queries: Update $$$sink[x] = sink[y]$$$.

Finally, reverse the $$$result$$$ vector.

Implementation

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

How to solve E?? is there any way to pass test case 5??

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

I took more than an hour to solve C but only 7 minutes for E.

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

Please, help me. Why I get WA on C: https://codeforces.com/contest/1620/submission/139816488 ?

»
2 года назад, # |
  Проголосовать: нравится +18 Проголосовать: не нравится

I think many people passed G with $$$O(26*n*2^{n})$$$, but it wasn't intended right?

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +41 Проголосовать: не нравится

    Unfortunately, it was hard to cut all of them off. The model solution works in $$$O(2^n \cdot (n + A))$$$, but its constant factor is kinda big so I couldn't set $$$n = 24$$$. In retrospect, perhaps it would be better to swap F and G and set something like $$$n = 20$$$ instead of $$$23$$$.

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

    How do you do it with that complexity? Is it even easier than $$$O((n + 26) 2^n)$$$? I can't imagine a solution where it is not immediately clear how to optimize.

    • »
      »
      »
      2 года назад, # ^ |
        Проголосовать: нравится +10 Проголосовать: не нравится

      Lol me too, but I think what some people did was to calculate for each mask, the contribution of each alphabet by iterating on all set bits instead of using the precomputed values and taking the low bit of mask.

    • »
      »
      »
      2 года назад, # ^ |
        Проголосовать: нравится +18 Проголосовать: не нравится

      One of the approaches I tried to cut off was based on the following dynamic programming:

      $$$dp[i][mask]$$$ — the number of different strings consisting of the first $$$i$$$ characters of the alphabet such that they are subsequences of every $$$s_i$$$ from the mask, and are not subsequences of any other $$$s_i$$$, with $$$O(A \cdot 2^n)$$$ states and $$$O(n)$$$ transitions from each of them.

    • »
      »
      »
      2 года назад, # ^ |
      Rev. 2   Проголосовать: нравится -16 Проголосовать: не нравится

      I used dsu like you in E but m getting mle and I have no idea why

      can anyone look into this .This would be a great help I encountered such thing first time my submission

»
2 года назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

Getting ready for a -100 LOL :p

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

I don't understand the gap

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

I don't understand the gap

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

I'm curious what's test 2 here that's causing WA.

https://pastebin.com/41BJXM9H

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

how to solve A?

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится -10 Проголосовать: не нравится

    Please don't ask me :((

  • »
    »
    2 года назад, # ^ |
    Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

    Let $$$cnt$$$ is the number of $$$N$$$ between $$$s_i$$$ and $$$s_{n-1}$$$.

    • $$$cnt = 0$$$ means $$$a_1 = a_n$$$ or $$$s_n = E$$$.
    • $$$cnt = 1$$$ means $$$a_1 \neq a_n$$$ or $$$s_n = N$$$.
    • Otherwise, there always exists a solution.
    Spoiler
»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Why so tight constraints! :/

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

solved D after contest ended 3min :D

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится -8 Проголосовать: не нравится

    Same dude, 1 minor mistake let maxx be the biggest element in array i didnt check if there were any maxx-1 — s elements in the array if maxx%1=3

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

No greedy,that I cannot solve any problems.

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

One Doubt , I submitted 1st Accepted Solution to C at 1:08 and second at 1:18 if the first one gets hacked or FST , the second one's final verdict will decide my rank ?

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    The second one will contribute, the first one is kind of nullified by your second submission.

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

      Thanks , In non educational Div 2 Rounds , Penalty for multiple submission (correct or incorrect ) is added in the standings while here no additional penalty is showing currently .

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

        I would have expected 10 minutes penalty per submission, the first one is free. But not sure.

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

Why is there TL on 5 test? Submission: https://codeforces.com/contest/1620/submission/139803575

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +22 Проголосовать: не нравится

    Because your complexity is not good?

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

      can you tell me what is the time complexity link of this solution, according to the constraints shouldn't this give solution gives tle?

      • »
        »
        »
        »
        2 года назад, # ^ |
        Rev. 2   Проголосовать: нравится +12 Проголосовать: не нравится

        It's $$$O(q \log q)$$$.

        It uses small-to-large merging, unlike the person I replied to. Basically this line is very important: if (y.size() > z.size()). It can sound unintuitive but in total, every element gets copied from one vector to another only $$$O(\log q)$$$ times (it's similar in the idea to HLD and union-by-size in DSU).

        Proof sketch

        So in total it's $$$O(q \log q)$$$. Also y.swap(z) takes constant time (I didn't know this) so no worries there.

»
2 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Really hard test case 3 in problem C for my small brain :(

»
2 года назад, # |
  Проголосовать: нравится -90 Проголосовать: не нравится

WORST round EVER!

Emplemetionforces and speedforces combined

bruh

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

I didn't get D... Somebody please explain the third and fourth case

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

C has an overflow issue.. I got too many WAs because of overflow issue

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

    Same :( I spend like an hour trying to find what to issue was, only to realize after the contest that it was overflow :(

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

D drove me mad...qwq

»
2 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Why my solution got Memory Limit error? I couldn't see what is the problem. https://codeforces.com/contest/1620/submission/139812356

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

very cool problems! managed to solve A,B and C, and it somehow felt like A stumped me the most. thank you for a good round.

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

I'm surprised nobody mentioned a solution using DSU for E yet. It's the first thing I thought of, could there be something wrong?

  • Initialize DSU to size equal to number of final array elements.
  • Maintain two mappings: (DSU leader -> value) and (value -> DSU leader)
  • Processing the queries seems straightforward..? The only things to be wary of are that when you need to merge values, the DSU leader of a component may change, and you need to make sure that only leaders are present in the mappings.
  • In the end, the value for index i, processed in increasing order, is the value of its leader.
»
2 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

I think D and E should have been swapped. E was as simple as simulating the process backwards.

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

Is there an etalon solution for problem E in Python3? My solution is O(n) but it exceeds time either on test 13 or sometimes on test 17 sometimes, even with fast IO

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

    Tried it in Python first too, got 2 TLEs, wrote the same code in C++, got AC.

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

    There is a lot — check out submission stats for a problem — and you can just switch to pypy3 sometimes it helps.  is yours code AC in pypy3.

    PS. And to add: you are creating a lot of objects (lists) to encode input. Try to simplify it and get rid of them.

    P.P.S. Or maybe not and I am wrong (about creating a lot of objects) — cause your solution is faster than my when I run it on PyPy :)

    PPPS. Oh, no, I was right, but you have reall-really-really good "fast-input". My solution become twice faster with it — thank you very much!

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

Can someone help with this submission?

https://codeforces.com/contest/1620/submission/139828156

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

Why is my code for C TLEing? 139829242

I think my complexity is O(n*k), where n<=2000, k<=2000

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится -10 Проголосовать: не нравится

    A given string may have b, but your program did not consider it.

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

      "...that consists only of characters 'a' (a lowercase Latin letter) and '*' (an asterisk)."

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +6 Проголосовать: не нравится

    You are overflowing LLONG_MAX (9e18) on the line temp *= (v[i]*k)+1;. This is undefined behaviour and you are TLEing because of this. Be sure to make sure that temp is not overflowed.

    • »
      »
      »
      2 года назад, # ^ |
      Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

      Thanks, took care of it and it passed. My dumb ass wasted too much time on this foolish mistake during the contest ;_;

»
2 года назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

This "hack" is borderline hilarious.

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

C >> D

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

I don't know if the intended time complexity of the solution for D is $$$\mathcal{O}(N)$$$, but checking only 7 possible patterns for cost of each bag receives AC verdict.

The patterns are:

Can anyone hack this solution? Submission:

  • »
    »
    2 года назад, # ^ |
    Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

    That is correct, in the optimal answer you get at most one 1-token and at most two 2-tokens.
    That is because you can always break two 1-tokens into one 2-token and break three 2-tokens into two 3-tokens thus getting a better answer always:
    1) (1+1) -> (2)
    2) (2+2+2) -> (3+3)

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

      Also, whenever cost of any bag is 1, we need to ensure atleast one 1-token is present.

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

Can anybody tell what I am doing wrong in C. solution link — c

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

Can someone explain why my memory limit is exceeding in my solution for C 139817111

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

How to solve problem F?

»
2 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

I passed C after the contest when i used unsigned long long rather than long long. Codeforces doesnt support cry emojis

»
2 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Thank you, too good to goodbye for 2021.

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

Am I the only one who found C much easier than D and E?

»
2 года назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

Why are contestants with ratings greater than 2100 being shown as official participants? will they be removed from the official list and then acc. our rating change will be calculated?

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

E can be simply solved by small to big technique. just merge. here is my submission 139852514

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

    Oh great i didn't knew that it is some technique. Well i discovered already discovered technique.

»
2 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

The Rating Result?

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

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

»
2 года назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

looks like problem A was the only problem nitin_05 could solve without buying solutions. XD

he got skipped except A

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    That problem not being skipped has worked to his disadvantage.

    If all the solutions would have been skipped then he would have no valid submission and the round would become unrated for him. However the solution for problem A not skipping means that the round is rated for him and due to only 1 correct submission , there's a huge negative delta.

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

Hello

I was suspected to cheat on the problem A with Shanto65 and atau004.

As you can see in this problem, it is very probable the everyone use this idea(and use a variable called cnt).

Dear codeforces please review this again(by the way i didnt use ideone or something like that).

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

Fake Plagiarism check to ban me from my own account. TheThinker_08. This has now happened several times. What you cant even write your own code now. And The other guy @Paul_Liao_1457 got no penalty just cause his score is greater than mine. please just look into this I didn't do anything wrong or copy from anywhere still got a plagiarism check and got banned just what is this

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

I have a question about E. in my opinion i have O(n) solution, but it gets TL at 5th test, can someone tell me what's wrong? Is it solution or it's just Python can't make it.

https://codeforces.com/contest/1620/submission/139826532

  • »
    »
    2 года назад, # ^ |
    Rev. 5   Проголосовать: нравится 0 Проголосовать: не нравится

    You are right about time complexity of your solution. What you are missing is that using input() for 500_000 of entries is too long. Look into other solutions to see "fast input" for python. Here is your solution with 1 variant of fast input: 139998877

    PS. And this fast-input: 139999694 I have just found in sur's solution is even better — it just made my solution twice faster. Thought, you should be careful with what you get — there will be unprintable symbols in your input.