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

Привет, Codeforces!

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

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

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

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

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

Отдельное спасибо тестеру раунда stAngel за ценные советы и предложения!

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

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

Harbour.Space
WORK & STUDY OPPORTUNITY IN BARCELONA @HARBOUR.SPACE UNIVERSITY

Harbour.Space University в партнерстве с Giga (Unicef) предлагают стипендию для получения степени магистра в сфере даталогии, а так же опыт работы.

Мы ищем различных кандидатов от junior до mid уровня:

Специалист по работе с данными:

  • Хорошие знания в области машинного обучения
  • Опыт работы с инструментами визуализации данных, такими как matplotlib, ggplot, d3.js., Tableau, которые помогают визуально кодировать данные
  • Отличные коммуникативные навыки – невероятно важно описывать результаты технической и нетехнической аудитории
  • Сильный опыт разработки программного обеспечения
  • Практический опыт работы с инструментами обработки данных
  • Способность решать проблемы
  • Аналитический ум и отличное деловое чутье
  • Высшее образование в области компьютерных наук, инженерии или смежной области приветствуется

Аналитик данных:

  • Подготовка данных
  • Анализ и изучение данных
  • Знание статистики
  • Анализ и визуализация данных
  • Отчеты и панели индикаторов
  • Общение и переписка
  • Знание предметной области
  • Ориентированность на решение

Все успешные кандидаты будут иметь право на получение стипендии со стопроцентной оплатой обучения (29 900 евро в год), предоставляемой нашими партнерами.

ОБЯЗАТЕЛЬСТВА КАНДИДАТА

Обучение: 3 часа в день

За год обучения вы завершите 15 модулей (длительность каждого 3 недели). Ежедневная учебная нагрузка составляет 3 часа, плюс домашнее задание, которое нужно выполнить в свободное время.

Работа: 4 часа в день

Погрузитесь в профессиональный мир во время обучения. Вы будете учиться у лучших и с первого дня сможете применять свои новые знания на практике.

ТРЕБОВАНИЯ

  • Опыт работы в отрасли
  • Международный опыт
  • Стремление к обучению
  • Устойчивое развитие ключевой момент для вас
  • Желание работать на общественную организацию
Подать заявку →

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

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

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

In blog : The problems were invented and prepared by ..., Roman Roms Glazov, ...
But in contests page Roms doesn't exist.

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

I'm always scared of educational rounds because I tend to do worse in them — but it's never too late to turn the trend around. Good luck everyone!

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

    its not just you buddy, these are just speed forces rounds lately. People solve till ABC and There is huge difficulty gap in C and D. Good luck :D

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

      Last One?

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

      but this time there is huge difficulty gap between B and C.

      Some people I saw that they solved D, but not C.

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

        That was me.. I had a stupid bug in my C sol lol. -100 delta for me, the trend continues xD

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

          same here, solved D in just 5 minutes but wasn't able to debug C

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

            Earlier educational rounds used to be educational. Now it's more like easily come up with the logic and implementation in 10-15 mins and debug the code for the corner case for next 20 mins. dsa problems have vanished entirely

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

              Nah now it's just sth like F being unsolvable for the very vast majority of people and E being some classical problem lmao

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

                Edu rounds can educate me that I can't become Master without a clear brain.

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

                  Edu rounds can educate me that I'm not at all educated...

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

    ya dalala

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

Thanks HARBOUR.SPACE UNIVERSITY

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

Hi all, it would help if you can post some insights/hints for the problems of this contest (AFTER it ends) on https://starlightps.org. Here is the collection for the problems of this contest: https://starlightps.org/problems/collection/cf-edu-154/.

This will help us get more data so users can have a platform to:

  • share/discover hints/insights on various problems
  • find similar problems given insights they struggled with.

Check it out if you're interested. Thanks!

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

goodgood

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

Get ready for the worst implementation problems like always

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

hope this round can reach 1200

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

Hope PinkieRabbit can attend this.

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

I'm unrated. Can I participate? I've never participated in any contest before. This is my first time in codeforces. :')

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

This is the last contest before the National Day holiday in my country.

I will do my best!

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

Wish no weak pretests again.

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

Hopes to get educated from this educational round

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

Hoping to get more educated in this educational round

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

Back-to-back contests

But educational codeforces rounds are more interesting

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

Good luck!

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

It seems that the standings is broken unusual currently (it shows all participants in official standings, even div.1). Could you please fix redesign this bug unusual design ASAP?

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

Will be delta calculated considering contestants from div. 1 or not?

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

Can anyone help and tell for which test case my solution is failing? Problem : C Submission link

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

C>>D.

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

adhoc forces

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

    I solved B, D and E using DP :)

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

      What was your states and transitions to solve E ?

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

        dp[i][j]: number of arrays of size i such that the last j elements are distinct

        if j = k then the last j elements form a permutation and if j>k it means the last j%k elements are distinct and there are j/k permutations not including the last j elements

        dp[0][0] = 1

        for transitions:

        dp[i][j] = (summation dp[i-1][l] where l>=j and floor(l/k)=floor(j/k), and l is not a multiple of k) + dp[i-1][j-1]*(k-j%k)

        k-j%k is the number of possible elements distinct from the last j%k, it's the number of possible ways to make the last j%k+1 elements distinct

        the number of possible ways to make only the last j%k — x numbers distinct is 1, just append the xth element from the end

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

How to solve E?

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

    I didn't solve E, but I think it maybe smth like $$$dp[i][len][count]$$$, where $$$i$$$ is a length of prefix, $$$len$$$ is the maximum suffix, where all numbers are distinct and $$$count$$$ is the number of obtained correct sequences of length $$$k$$$. The number of states is not more than $$$N * K * N / K = N^2$$$, so it maybe correct if all transition is made no longer than $$$O(1)$$$. But unfortunately I got confused in the transitions :(.

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

How to solve D? do we need to consider some increasing and decreasing slopes?

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

    You can make some prefix negative and rest all positive.

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

      Can you tell me how you came up with this intuition? A lot of people found this fairly easy but I couldn't come up with any solution.

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

        First, assume we are only dealing with positive numbers. For any adjacent a,b, if a>=b, we will have to multiply b and all numbers after it Proof assume there is a c after b. If b is already less than c, multiplying both is the surest way to preserve that. If b>=c, then (again, with positive numbers) no matter what we do we can't change that, so it's still fine to multiply both.

        Now we can extend this to negative numbers using similar logic (replace a<=b with a>=b). Since we need a strictly increasing sequence, we can do a single transition from negative to positive numbers, but it may not be necessary (all negative/all positive could be better).

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

3 contests in a row solving E but can't finish in time, fuck

smb please tell their solution to E?

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

    Same to me for problem C. Long way to go on the revenge journey.

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

    I solved by finding, "in how many arrays does some subarray contribute?"

    For this, I use a dp state where dp[i] gives number of arrays of length i, such that the subarray ending at the last index is used.

    Now for calculating dp[i], we can first see that elements from i-k+1 to i should form a permutation of k, and for the rest, we can give any element from 1 to k. So we initially set dp[i] to be k! * exp(k,i-k).

    Now we need to subtract those arrays from dp[i] which have their last used subarray ending at some index in the range [i-k+1, i), because it will intersect with our subarray ending at i. Suppose we have an array ending at j, which lies in [i-k+1, i). So number of arrays such that last used index is j, and [i-k+1,i] still forms a permutation is dp[j] * (i-j)!. We subtract this value from dp[i] for all j in [i-k+1, i).

    Now our answer is the sum of contributions of all subarrays, so we can simply sum up dp[i] * exp(k,n-i), because for all elements after i, we can place anything we want.

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

Took so much time for C, couldn't even think about D much. How to solve D?

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

    Divide the array into two halves, make first half negative ascending and second half positive ascending. Pick the best answer among all possible half partitions (you can also make all positive and all negative).

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

    If you only multiply by positive number then the answer would be number of elementsi such that a[i]>=a[i+1]. Instead what we can do is for some i turn the prefix before it to a negative increasing array. If the prefix contains k strictly decreasing segments then the number of operations needed to convert the whole prefix to an strictly increasing prefix such that all it's elements are negative is k. So we can just check it for each index i and calculate the minimum

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

How to solve Problem D? I couldn't solve it, got a headache from Problem C :(

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

I feel D<C and the implementation of C was complex. What's the easiest solution for C?

my submission: 221301419

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

    You just need to maintain 3 variables: current_number_of_element, sorted_till(default = 0) and unsorted_from(default = inf) and do casework.

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

    I created a tree and checked for validity using dfs.

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

    I used a lazy segment tree for C

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

      I don't think I've seen this level of overkill since this

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

        It's not overkill at all. I just copied the tree and then implemented it within 5 minutes. I believe it's the easiest and quickest approach to solve problem C.

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

          Hi, can you explain your solution how it works ?

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

            Maintain a pointer and a lazy segment tree where each node in the tree is assigned one of three values: 0, 1, or 2, representing "not sorted," "sorted," and "unknown" respectively.

            Consider each type of query as follows:

            • "+": Increment the pointer by 1 and set the corresponding value in the tree to 2.

            • "-": Decrement the pointer by 1.

            • "0": If the node's value at the pointer position in the tree is 1, the answer is "no". If it is 2, set it to 0.

            • "1": If the minimum value in the range [1, pointer] of the tree is 0, the answer is "no." Otherwise, set all values in the range [1, pointer] to 1.

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

      💀

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

    I kept track of L = current length of the array, A = the maximum possible number of sorted elements, B = minimum possible number of sorted elements. If B == L, then 0 is impossible. if A < L, 1 is impossible.

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

      This makes sense to me. It's short to implement and lighter casework. 221383919

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

      For a long time I could not understand the author's solution to this problem, but I understood your explanation right away, it is so simple and understandable. Thanks a lot!

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

    Let's make a stack which maintain values where 0=unsorted from here, 1=sorted until here, 2=unknown.
    When processing query=='+', if stk.top()==0 then stk.push(0) (to propagate info) because array is unsorted obviously, else stk.push(2).
    When processing query=='-', if stk.top()==1 then do{stk.pop();stk.top()=1;} (to propagate info) because array is sorted obviously, else just stk.pop().
    my submission: 221294647

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

    I used a stack: 221370839

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

    Maintain a stack of states : 1 if sorted, 0 if not, -1 if both possible. When you add an element it's either 0 if the array is already not sorted, or -1 (since the last element can be decreasing too). For the queries : if last state is -1 and array is sorted erase all the minus ones and replace them with ones.

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

    My 3 variable solution: 221315344

    (same as described by adityagamer)

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

How to solve C?

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

How to solve C?

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

    Pure implementation... Just playing around with booleans an conditions, but it's a bit complex

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

    If a prefix of an array is not sorted, the arrays to which the prefix belongs is also not sorted. If array is sorted, all its prefixes are also sorted. Just simulate operations from left to right and keep track of the state of the prefix (whether it's sorted, not sorted, or no idea), if you find a contradiction, answer is no otherwise yes.

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

C is so bad

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

C is so bad

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

A & B these two problems are implementations?

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

Huge increase in difficulty from D to E. Why is it that only GM or LGM-s can solve last problem on div 2? It's rated under 2100 but not expected to be solved someone under 2100.

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

C was a brilliant problem.Took me an hour to realise it could be solved by set and lower bound.

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

    can you explain your solution?

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

      Yeah. - First for the unsorted part '0' : After marking the array unsorted I maintained a "ct=1" variable that increments on '+' that comes after '0'(unsorted) and decrements on '-'.If the ct reaches 0 at some point that means the array is no more unsorted and the ct is restored to 1.This continues and handles all the cases for '0'.

      • Now for the sorted part : Lets say the array is sorted at count no.7 then it will sorted for all (less than)<7 as well.So I mark the array sorted and insert 7 into the set.Now if I encounter a '-' and the count no. drops back to 7 then I find and erase it from the set and insert (7-1)into the set else lets say if I encounter another '1' at some point then I again insert that current count into the set.This way I can keep track of all possible positions where the array could be sorted.Now if I see a '0' I can simply use lower bound on the current count to make sure whether the array is sorted or not.This handles all the cases for '1'.

      It might be confusing for some people, provided that I used lots of trial and error methods to get this idea.

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

    it can be solved without using any data structures

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

A: One of "13" and "31" will be a subsequence of permutation of [1, 9], and both of them are prime.

B: Note that during the operation, the occurence of substring "01" can only be removed but can't be created. Since the first and last character can't be changed, there will be occurence of "01" in both a and b after operation, and they need to occur at the same position, so there must be some position that "01" occurs at this position both in a and b initially. On the other hand, if a[i]=b[i]='0' and a[i+1]=b[i+1]='1', we can do operation (1, i) and (i+1, n) both on a and b, then a and b will be the same.

C: We need to maintain 2 values: pos1 = the leftest possible position such that a[pos1-1]>a[pos1], pos2 = the maximum possible prefix such that a[1, pos2] is sorted. When we process query '0', we need to check if pos1<=length, then let pos2=length-1, and for '1' we need to check if pos2>=length, then let pos1=inf.

D: Suppose we need to make a[1, k] negative and a[k+1, n] positive. For making a[k+1, n] positive and sorted, we need a operation for each k+1<=i<n and a[i]>=a[i+1]. For making a[1, k] negative and sorted, we need a operation for each 1<=i<k and a[i]<=a[i+1], then we need an extra operation on [1, k] multiply by -1. Therefore we can solve the problem by keeping prefix and suffix sums.

E: When solving the problem for a single array, we can solve by greedy: Iterate i from 1 to n, when a[i-k+1, i] is a permutation and doesn't intersect with any subarray we've taken, we take it as a valid subarray. Let dp[i][j] = the answer when we consider arrays of length i and the length of the maximal suffix without duplicate elements is j, cnt[i][j] = number of arrays of length i and the length of the maximal suffix without duplicate elements is j. For 0<=j<k-1, the update is dp[i][t] += dp[i-1][j] for 1<=t<=j, dp[i][j+1] += (k-j)*dp[i-1][j] (similar for cnt[i][t]). When j==k-1, adding the missing number of the suffix with length k-1 will create a new permutation as a subarray, so the answer need to be increased: ans[i][0] += ans[i-1][k-1] + cnt[i-1][k-1], and for 1<=t<k, we have ans[i][t] += ans[i-1][k-1]. Thus we can solve the problem in O(n*k) by using prefix sum for range updates.

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

Best contest of my life, Thanks. UwU

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

This guy v6ishal is streaming contest live on youtube. Is there something that can be done? Link to the video : https://www.youtube.com/live/JLoIIk9S_F0?si=MASh06PY_pKUhj22 Channel Link : https://youtube.com/@v6ishal?si=uUk4r0I3VbBfbeI_

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

Am I the only one who thinks the sample testcases are too weak? T_T

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

    +1

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

    btw, I upsolved problem D using DP. I noticed that most contestants solve it with some observations. If anyone's approach is similar to mine(not a good "observer" haha) and is stuck in WA, I hope my submission will help!

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

      hard dp to understand, maybe you can explain what is f[i][j]?

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

        $$$f_i$$$ is the answer considering $$$[1,i]$$$.

        $$$f_{i,0}$$$ is the answer when we modify $$$a_i$$$ with a negative number, and $$$f_{i,1}$$$ is the positive case.

        Then the following process is kinda natural. If $$$a_i$$$ and $$$a_{i-1}$$$ can satisfy the restriction in one operation, the answer is equal(just "extend" the operation from $$$i-1$$$ to $$$i$$$), otherwise it has to $$$+1$$$.

        • $$$a_i> a_{i-1}$$$
        • $$$f_{i,1}$$$: whether $$$a_{i-1}$$$ is modified positive / negative, $$$a_i$$$ can be greater than it without another operation("extend" the operation / just do nothing), so $$$f_{i, 1}=\min(f_{i-1,0}, f_{i-1,1})$$$.
        • $$$f_{i,0}$$$: if $$$a_{i-1}$$$ is positive, it doesn't make any sense for $$$a_i$$$ to be negative, and we don't consider that. If we extend the negative operation on $$$a_{i-1}$$$ to $$$a_i$$$, $$$a_i$$$ will become smaller. So one more operation is required. $$$f_{i, 0}=f_{i-1,0}+1$$$.
        • $$$a_i< a_{i-1}$$$
        • $$$f_{i,1}$$$: if we extend a positive operation on $$$a_{i-1}$$$ to $$$a_i$$$, $$$a_i$$$ is still smaller, so one more operation is required. if $$$a_{i-1}$$$ has become negative, we do nothing. $$$f_{i, 1}=\min(f_{i-1,0}, f_{i-1,1}+1)$$$
        • $$$f_{i,0}$$$: if we extend a negative operation on $$$a_{i-1}$$$ to $$$a_i$$$, $$$a_i$$$ will be greater than $$$a_{i-1}$$$ and we don't need to spend another operation, $$$f_{i, 0}=f_{i-1,0}$$$.
        • $$$a_i= a_{i-1}$$$ is a mix of the above.

        thus $$$\min(f_{n,0}, f_{n,1})$$$ is the final answer.

        ah, it looks the nested markdown list is broken...

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

Did anyone else solve B using dp because it seemed simpler than trying to find a greedy solution or is it just me?

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

It was the worst Educational round (in my opinion), thanks to BledDest, Neon, Roms, adedalic and awoo!

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

Can someone explain me why my code fails on problem C 221348457

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

A was very tricky

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

.

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

this isn't an educational type round imo. just tricky constructive implementations

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

Can i get a hint on intended sol for B?

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

Since when does CF give penalty for failing on samples?

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

    Since the beginning. It only doesn't give penalty if you fail test case 1 in order to avoid cases of "I accidentally submitted the wrong code". But if you fail test 3 and it's in the samples it's still going to give penalty.

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

Does anyone have an example where doing a prefix sum instead of suffix sum for D doesn't work?

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

    What exactly do you mean by that?

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

      When I made my dp array to count the number of operations needed to convert the array to strictly increasing, I just made a prefix sum array and assumed I could've just taken some suffix from it, instead of making a suffix sum.

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

        I did the same way. I guess your implementation is wrong in some corner case, don't know where exactly. Maybe my solution might help

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

          Hmm that's weird. I just set the first index as 0 and just iterated thru and added 1 if current element is <= prev element

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

Is Someone tell me how to i solve A & B fast in div2 contest. To give me any advice. Thanks.

  • »
    »
    8 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится
    1. Fast is subjective, fast for a Red coder is a smaller than fast for a specialist or a pupil.
    2. Fast for a new joiner is bigger than fast for a veteran.

    These two statements say 1. Don't compare yourself to others who have greater inherent skills than you, 2. You have to compare yourself to your past self.

    My suggestions: 1. Watch this video: https://www.youtube.com/watch?v=tsNv9F3DGpQ. 2. Train your speed skills, maybe by making contests with x easy question for a duration of y minutes (Codeforces has this feature), and try to solve as much as you can during these contests. You then track your performance change (If any).

    This what came to my mind.

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

    Practice Cs, a and b will seem easier and you could get them faster.

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

Help me explain problem C. test case: ++++0++---1. why the result is TRUE

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

    List of numbers inserted in order: 1,2,4,3,5,6.

    The first 4 elements are not sorted so the 0 and after inserting remaining 2 elements you remove the last 3 elements which leaves us with1,2,4 which is sorted so the 1.

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

    It's possible to be like this:

    1. ++++ -> 1231.
    2. Not sorted
    3. ++ -> 123111
    4. --- -> 123
    5. Sorted
  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится
    1. arr = {1}
    2. arr = {1, 2}
    3. arr = {1, 2, 3}
    4. arr = {1, 2, 3, 2}
    5. arr = {1, 2, 3, 2} => 0
    6. arr = {1, 2, 3, 2, 3}
    7. arr = {1, 2, 3, 2, 3, 3}
    8. arr = {1, 2, 3, 2, 3}
    9. arr = {1, 2, 3, 2}
    10. arr = {1, 2, 3}
    11. arr = {1, 2, 3} => 1
  • »
    »
    8 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks everyone, I misunderstood that 0 is sorted in descending order :((

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

    until the array size reach 4 you don't know weather it's sorted or not when the array size becomes 4 0 appears which means array is not sorted and it can be due to 4th element or any of the first 3 elements after that 2 elements added last 3 elements removed we are left with first elements and we don't know weather it's sorted or not so it can be sorted sorted and the sequence is correct for eg:- add 1, add 2, add 4, add 3 -> unsorted add 5, add 6, remove 6, remove 5, remove 3 array becomes 1, 2, 4 -> sorted

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

    for each + sign append the following number

    2,3,4,3

    after this it is 0 so the array formed is unsorted again for each + append following number

    2,3,4,3, 5,6

    now remove three number from last as we have — then we get 2,3,4 after this it is 1 and also the array is sorted so it is true.

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

Can anyone explain the observation of problem B as A[i] == 0 and A[i+] = 1 for some index for both A and B?

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

    If for any index i we have A[i] == '0' and A[i+1] = '1' we can select that index to make the string 00...00 upto index i and 11...11 from index i+1 to n-1. So we try to find such index which can help us create such string and is possible for both the given strings.

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

Video Editorial for Problem A,B,C,D.

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

I spent an hour getting wa on prob B because I forgot to check the case that two strings already equal :(

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

Can anyone please tell error in my soln for problem C. I am getting WA on 2638th test case 3. 221366386

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

    same for me bro, I have -12 at C and I'm gonna lose my specialist :(

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

      I got my mistake. When a[i]=='0' then i was doing uf = nums but it would be: if(uf==-1) uf=nums; else uf = min(uf,nums);

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

First two solution by recursion

1) Problem A

2) Problem B

Upvote If u like my solution

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

E is very cute

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

Can anyone provide a counter example for this submission for problem C — 221365170

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

    you may try this testcase: 1 ++0++0++0--1 expected: NO your solution output : YES

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

      Damn this was the case that caused the whole problem for me yesterday!! Let's smile and move on :') .

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

can someone explain how to do D with dp approach, i am not able to think that

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

I always find educational rounds tricky.

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

ABCDE are all doable but I wasted too much time on C just to figure out how to implement "properly".

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

My first program in Codeforces is in this contest.

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

Disappointed that i could't solve problem D during contest.It was doable and bit easier than usual problme D of educational rounds.

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

Hi all, it would really help if you can post some insights/hints for the problems of this contest on https://starlightps.org ! Here's a link to the problems: https://starlightps.org/problems/collection/cf-edu-154/. This will help us get more data so users can have a platform to:

  • share/discover hints/insights on various problems
  • find similar problems given insights they struggled with.

Check it out if you're interested. Thanks!

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

Can someone please help me out with the following solution for problem c?221343682

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

Had been solving 3rd problem from the last 6 contests, Couldn't solve this time

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

Why should there be no pretesets in problem C with |s| = 2 * 10^5?

I set my N ( MAXN ) equal to 10^5 and got time limit on system testing. :(

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

In problem c can anyone tell me where my code fails this on

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

    ++0++-1
    It should output NO

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

    can u tell me how u think of checking 0 and 1 ...in both strings..in problem 2..please explain me problem 2 solution intution

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

      the reason here would be that if such an i exist such that a[i]==b[i]==0 and a[i+1]==b[i+1]==1 then we can make both strings from index 0 to i to 0 and from i+1 to n-1 to 1(0 indexed).

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

Waiting for rating change.

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

hackational codeforces round

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

Can someone explain me why my code fails on problem C 221400131

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

When will editorial drop?

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

why is it unrated for me?

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

Why is it unrated for me?

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

I am waiting for the moment to reclaim my blue.

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

    i am waiting to become specialist for the first time :( why are the rating changes taking so long

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

      Nothing can make us happy without patience

      I think the rating changes will be executed soon!

      Enjoy your day ^^

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

Is there a math solution for problem E?

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

My solution for C got accepted during the contest, but it now shows TLE. Day ruined :(

»
8 месяцев назад, # |
Rev. 4   Проголосовать: нравится -8 Проголосовать: не нравится

why ML in B so tight, what is the point of cutting off dp solution ?

UPD: my bad, I know dp solution (221428793) can be implemented in O(n) space complexity, and I will more care about space complexity next time

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

I couldn't be any more unlucky. Missed 2100 by 1 rating point :(

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

++++0++---1

For problem C How the answer is YES here. Because 0 is used to represent decreasing array right ? So should we break and print NO ?

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

    No, O is used to represent an unsorted array. It do not necessarily need to be decreasing.

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

      I also want to clarify on this.

      Can you explain why it is: YES for ++++0++---1 NO for ++++0++--1

      Can you also please draw out the patterns for clarity.

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

        For ++++0++---1 the array may look like this:

        1 2 3 2 -> for the first four plus signs

        as the array is now unsorted the state is 0

        then add two more numbers and the array becomes -> 1 2 3 2 2 2 Now remove three number from the back -> 1 2 3

        As the array is sorted and the state is 1

        So the answer will be YES

        For the second one try out yourself now.

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

What is case 58 of test 3 in problem D? I've been trying to figure out what's wrong with my solution since yesterday but I can't figure it out. Can someone tell me what that test is, or help me find a counter example for my solution? Link to my solution: Your text to link here...

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

Where is the editorial?

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

Problem E...

say DP(n) = total sum of costs of arrays of size n.

DP(n) = C(k) * (DP(n-k)+1) + C(k + 1) * (DP(n-k-1)+1) + ... + C(n) * (DP(0) + 1)

But I can't get formula for C(i), number of arrays of size i, such that only the last subsegment of length k has pairwise distinct elements.

Can someone help, please? ;((

EDIT: (mistake in DP(n), I think it should be: DP(n) = C(k) * (DP(n-k)+k^(n-k)) + C(k + 1) * (DP(n-k-1)+k^(n-k-1)) + ... + C(n) * (DP(0) + 1)

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

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

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

Hello everyone. I am getting a hard time understanding of Problem D editorial. Can someone please explain in a different way or shed some light. Thanks I really appreciate it.

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

Does anybody knows similar problems to D? For me wasnt obvious getting the intuition such that the optimal approach is making a prefix negative and keeping the rest positive. Once you get this idea it gets obivous how to proceed, but understanding this is not at all. I belive there is some similar problem which teaches you to think this way.

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

Does anyone know the 682th token for tc3 for C? My soln is here: soln although it maybe be abit unreadable

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

Overall good contest C was little tougher.

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

Why Was My Submission Skipped Despite Submitting First

https://codeforces.com/blog/entry/120756