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

Привет, Codeforces!

В 22.04.2022 17:35 (Московское время) состоится Educational Codeforces Round 127 (Rated for Div. 2).

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

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

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

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

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

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

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

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

As a specialist give me positive contribution pls

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

Contest rain,,,, Contest week....

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

hopefully will be as hard as the div 4

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

Coders after attempting div 4 round: Coding is not too tough ;-;

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

That's great! So many rounds :) Good luck everyone on the round!

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

It's raining, contest hopefully, I end up with a positive rating change after this week.

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

Wow, Educational Codeforces Round 0x7f! Wish to have fun and high rating!

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

Hope I turn pupil this round.

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

waiting for it

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

So Many contests back to back . I like it picasso

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

contest sleep again contest and again sleep....

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

It always astonishes me that someone can AK edu faster than I AK div4...Holy....

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

Happy to say that this is my first unrated edu round :yaaay:

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

ContestForces

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

I hope I can solve one problem

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

After div 4 I guess the first problem today in Edu is harder than the latest problem in div 4 yesterday :)

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

This will be the first edu round I join!

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

From question's perspective, is there any difference between normal and edu rounds?

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

What should we do when we feel very demotivated after wrong answer on Test 2?

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

Thank you for the round! Will reach master finally (If I don’t get hacked)

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

Enjoyed the contest, interesting problems and ideas, especially F.

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

-I gonna participate in edu today! That`s my first time !

-Are you sure you wanna give up programming today?

-Umm what?

-Never mind, my child, never mind

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

Something was changed in the way the authentication (or something else?) works. I cannot use CF tool, login fails.

Any workarround available?

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

How to Solve D?

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

    Note that any x[i] that is between min(a[]) and max(a[]) can be placed somewhere for free, since there exist two a[i],a[i+1] where that x[i] fits in between.

    So we are left with some x[i] like 1...min(a[])-1, and max(a[])+1,...,x

    The smaller ones (if some exist) can be placed in front of the first element, after the last element, or between the two elements with value min(a[]).

    Same goes for the greater ones.

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

      So then we just look over all possible locations of smaller and greater ones, right?

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

        Well, if min(a[]>1), then we have placed the x with value equal min(a[]) next to that min a[i]. Then we can put the remaining x[] (with values 1...min(a[]-1) between those two elements with value min(a[]), for the cost of 2*(min(a[])-1).

        The same goes for the bigger elements, if x>max(a[]).

        see 154578729

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

          Hi, wouldnt this fail for x < min(a[i]) though? I did exactly this in the contest, But made an exception for this case which resulted in WA.

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

            You probably got confused because of the assumption that the minimum element always occurs at least twice.

            Think of a test like this: $$$[20, 5, 6, 20]$$$, having $$$x = 3$$$. You can see that the sum of absolute differences equals $$$30$$$ before inserting the extra values.

            Now, according to spookywooky's code, $$$min(20 - 1, 20 - 1, (5 - 1) * 2) = 8$$$ is added to the final answer, which is clearly the optimal solution.

            You can think of adding the absolute difference between $$$2$$$ integers to the solution as if you decreased the maximum of these $$$2$$$ integers to the minimum (made them both equal).

            In the previous example, $$$5$$$ is the minimum and it only occurred once. However, after adding the absolute difference between $$$5$$$ and $$$6$$$, you can now assume that there are now $$$2$$$ occurrences of the number $$$5$$$ (which is the minimum) in the array.

            The same goes for the segment from maximum $$$+$$$ $$$1$$$ to $$$x$$$.

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

    notice that you need to find only min max from given array
    then you need to handle ranges 1..(min-1) and (max+1)..x
    so you can put them in the beginning, in the end or between some a[i]-a[i] pair if a[i] lies between given 1..x range

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

Solved 5 DIV2 tasks for the first time

low asymptotics tasks be like

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

For me D is painful. If you have a clean solution, then you are doing great. But I was using a complicated case solution and didn't resolve all cases correctly during the contest. I thought my case analysis was correct, but I kept getting WA on test 2.

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

Idea for D ?

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

первые пять как обычно безыдейны, ну ладно, хотя бы рейтинг поднимаю

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

Who can really prove the greedy solution for D ?

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

    When you put $$$x$$$ between $$$a$$$ and $$$b$$$ (assume $$$x \gt a \gt b$$$), the difference turns into $$$(x-a) + (x-b)$$$ where it used to be $$$a-b$$$. So the difference delta is $$$delta=(x-a)+(x-b)-(a-b)=2(x-a)$$$. Since when you put $$$x$$$ $$$(x \gt max)$$$ between any two elements the delta can only be greater or equal than $$$2(x-max)$$$ and you can actually achieve that equal, it is the optimal solution. Then just simply consider the case that you don't put it between any two (meaning that you put it at the beginning or at the end).

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

В задаче Е необходимо было написать условие про модуль в основную секцию описания, а не в формат вывода – как результат много WA28.

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

What do you think? Why in B problem's description there is no such case "you don't have to change every number". Many coders thought we have to change every element and we have one unsuccessful attempt xD

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

In problem E, why the output in the first example is 16?

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

In problem E

Can someone explain me what is the different between two codes? 154575910 and 154578191

Why one of them accept and the other not.

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

How to solve C?

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

    I did with some wiered two pointer like aproach.

    Note that we can never buy more sugar than on first day. So create prefix sums of the sorted prices, and binary search the number of shops we can visit on day 0.

    Then we can buy the same amount of sugar maybe for some more days. Calculate this number as $$$(x-sum)/cnt$$$

    So after that number of days, x is not enough to buy that number of sugars any more. So decrement the number of sugar until x is enough to pay that new number of sugars. Then the same repeats... until number of sugars is zero.

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

    Answer this question : At what days range we can buy $$$k$$$ number of items? (For each $$$1 \le k \le n$$$)

    To answer that question, we can use binary search. We can buy $$$k$$$ candies at day $$$d$$$ if $$$(a_1 + ... + a_k) + k \times d \le x$$$ (in other words, our money csn buy $$$k$$$ number of items)

    We can use greedy to prioritize the cheapest item first and use prefix sum to count $$$a_1 + .. + a_k$$$

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

    Sort the array from cheapest to most expensive. Go from left to right through the array to calculate a prefix sum up to this point. Also store in another array how many days you would be able to buy the with current configuration $$$(x-sum[i])/cnt[i] + 1$$$. Then go backwards through the array $$$i=n\dots 1$$$: you buy all packs you haven't already bought with the previous configuration: $$$(cnt[i+1] - cnt[i]) * i$$$

    154535703

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

Despite the slow start, I am happy that I could solve three problems for the first time in Div 3 or higher.

Not sure how I did better today than yesterday's div 4, maybe it was a good warmup.

Thanks for hosting.

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

This contest be like:

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

such a fun contest. really enjoyed C and D

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

C is good.

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

great contest ..problem C is NICE

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

GREAT CONTEST..I REALLY ENJOY ..PROBLEM C IS NICE

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

How to do E?

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

If you prefer command line, checkout CF Doctor for more flexibility and faster feedback.

If you are/were getting a WA/RE verdict on problems from this contest, you can get the smallest possible counter example for your submission on cfstress.com. To do that, click on the relevant problem's link below, add your submission ID, and edit the table (or edit compressed parameters) to increase/decrease the constraints.

If you are not able to find a counter example even after changing the parameters, reply to this thread (only till the next 7 days), with links to your submission and ticket(s).

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

weird ""mathy"" problemset but ok I'll take it (upd: i dont)

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

HI everyone~ I have given two contest but can not solve a single questions. Is CP is not for me?

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

Felt confident thinking I could do E but then realized why the first test case was 16 and said nope! Anyone else feel the same? Haha

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

    my confident ass, trying to count the number of As and Bs to determine if the string would be unique or not only to get to know, in first test case, that it won't be enough they still can be unique.

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

Video Solutions : A-D

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

In problem E, I misunderstood the problem and think the input string is "preorder string" then get WA...

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

Any ideas and hints to solve Problem C?

I tried to brute-force it but got a TLE on tc 3.

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

    You have to sort the array, and then for each i, calculate the maximum number of days you can buy only from the first i shops in the sorted array. This can be done in this way: (x — pre[i])/i, where pre is the prefix sum till i

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

When will the rating be changed? The next contest will start. :[

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

why this sub for c gives TLE 154641815 ? bug or bad idea

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

Every time I participate to such a round I always get ripped off. Gotta tip my hat to those that make these tasks for managing that.

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

Can anyone point out why I'm getting TLE on TestCase 7, in my submission 154567604 for Problem C ?

For each shop, I am doing Binary Search to find the no. of days. Isn't, O(n*logn) sufficient?

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

When will the editorials be uploaded?

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

Hello I cheated from a classmate without him knowing. I want to correct my mistake and admit to what I have done wrong because I got the rating increase while the other person didn't. I hope admins could make this right.

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

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