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

Привет, Codeforces!

В Dec/18/2023 17:35 (Moscow time) состоится Educational Codeforces Round 160 (Rated for Div. 2).

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

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

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

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

Набор задач частично пересекается с Открытой Олимпиадой КФУ, поэтому если вы участвовали в ней — пожалуйста, воздержитесь от участия в раунде.

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

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

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

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

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

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

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

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

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

Front-end разработчик:

  • Уверенное понимание HTML, CSS и JavaScript
  • Знакомство с фронтэнд фреймворками и инструментами, такими как React или Vue.js.
  • Навык решения задач, внимание к деталям и страсть к созданию интуитивно понятных пользовательских интерфейсов имеют важное значение

Full-stack разработчик:

  • Интерес и опыт в разработке веб-приложений, информационных продуктов и OpenAPI
  • Умение работать с облачными службами развертывания (предпочтительно Azure), конвейером Git и CI/CD, а также процессами развертывания.
  • Приветствуется опыт работы с проектами с открытым исходным кодом
  • Уверенное знание ML
  • Опыт работы с инструментами визуализации данных, такими как matplotlib, ggplot, d3.js, Tableau
  • Отличные коммуникативные навыки — важно описывать результаты для технической и нетехнической аудитории
  • Большой опыт разработки программного обеспечения
  • Практический опыт работы с инструментами обработки данных
  • Способность решать задачи
  • Аналитический склад ума и отличное деловое чутье
  • Степень в области компьютерных наук, инженерии или смежной области приветствуется

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

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

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

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

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

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

ТРЕБОВАНИЯ

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

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

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

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

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

i wish, i can solved the C no problem in this round ...!

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

    i want to know the end of the story how many problem did you solve ?

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

      i had done problem A is after 1 times trying and problem b is after 3 time trying.... and didn't touch problem C ...cause i had maybe 7 to 10 minute left after solving A & B... and i got maybe -37 ratings after this contest (According my standing on this contest).

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

        sad but i become grey from green in this round...although ratings is nothing i still very sad

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

          no issue brother..please don't be sad...the last div 3 contest (in the past night)...i can't solved the problem A in 1 hours 10 minute and then i ditch the contest...it's hurts me a lot yesterday...but i am okay today...somewhere, i had read..."A master has failed much times that a newbie doesn't even try"...this line inspired me a lot...so don't be sad brother...i hope...one day we will became RED coder...just keep trying brother...!

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

            in fact,i solve 6 problem last night(i never do it before) you do not solve A maybe because you just do not see this kinds of question before. Try to solve more question!

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

Gl for everyone!

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

Hope the questions are not confusing.

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

I'm back with one more post-contest discussion stream
I will discuss the problems I solve in this contest.

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

Educational rounds are always exciting, don't know what they surprise.

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

hope i get positive delta :D

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

For some reason I didn't get the notification that the round would be unrated for me (rating must be between 0 and 2,099), and there is no unrated marking on the registrants list. Is this intended (or am I misremembering)?

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

Sometimes the educational rounds being hard for me But I feel this one will be interesting ☺️

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

Hope to become specialist this round!!!

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

Is it rated?

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

Hoping to perform better than my previous contest.

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

What's the difference bwtween normal rounds and educational rounds? It really bothers me.

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

    Different scoring type and usually educational rounds are supposed to be "education" so you might encounter more standards.

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

      So educational rounds have less ad-hoc problems and require us to use standard algorithms more?

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

        Not necessarily. It might have more standard but still needs ad hoc and similar. Tbh not too different from a normal . For example last round had ad hoc problems but problem E was standard problem.

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

USACO bronze annually is clashing with this contest :(

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

let's make it Cyannnnnn

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

Hope to become an expert after this round.

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

What is the difference between edu and general round?

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

goodluck everyone!

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

Speedforces

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

C <<<< D

i think there is huge gap between them

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

    I couldn't able to come up with an solution for this problem tried using bit manipulation but got wa on testcase 3 do we have to solve this using any other approach.

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

      you mean problem C?

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

        yes

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

          My solution for problem C

          To count how many we have for each power use vector or just ordinary array with 30 elements for each power of 2 that could be entered (0 to 29).

          For the first type of operation, just increment that value in the vector.

          For the second type of operation, go through from 29 to 0 and subtract until the values are finished(refer to the first vector for how many you have with that power of two) or v which was input has less value than the power of 2 we want to subtract. At the end, check if v is 0 or not, if it is answer is "YES", otherwise it is "NO"

          You can refer to my submission here: 237768705

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

            Great approach,thanks for sharing your approach. according to you what will be the rating of this problem

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

            Thank you for sharing

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

            Another approach....

            while (n--)
                {
                    ll a, b;
                    cin >> a >> b;
                    if (a == 1)
                    {
                        v[b]++;
                    }
                    else
                    {
             
                        vector<ll> tm = v;
                        ll carry = 0;
                        bool flag = true;
                        for (ll i = 0; i < 30; i++)
                        {
                            tm[i] += carry;
                            if ((b & (1ll << i)))
                            {
                                if(tm[i] == 0)
                                {
                                    ctn;
                                    flag = false;
                                    break;
                                }
                                tm[i]--;
                            }
                            carry = (tm[i] / (ll)2);
                        }
                       if(flag) cty;
                    }
                }
            

            So to calculate we can get w from out list or not , i just started traversing each bit of w , if at ith bit is 1 in w then we will look that we have ith bit or not in hashmap.If No then we print NO , If yes then decreament ith bit from our hashmap. if there is still some remain in ith bit then we can push it ahead , like we have m[2] = 3 and we have used it one from it so now we had 2 that is (2^2 + 2^2) we can write this as 2^3 so we can increament m[3] by 1. so in genral we have count extra for ith bit then we can increament m[i+1] by floor(count/2.0).

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

good contest

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

How to do E?

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

    Using Flows

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

    I guess, Flows with Demands should satisfy the problem. Just throwing in some virtual nodes for outflow from each node and inflow to each node should do the job. Here, a node is a row/column, and edges are delta-based flows on flipping cells. Note that we know the original sum across rows/columns, and only care about needed deltas through flipping. This delta determines the demands on inflow/outflow virtual nodes.

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

      Agree. I'm about the same.

      Use minimum cost maximum flow. Specifically, create a node x[i] for each row i and a node y[j] for each column j.

      For each cell in the i-th row and j-th column, create an edge (x[i], y[j]) with a flow of 1. Flow represents filling the cell with 1. If the cell originally contains 1, calculate the cost in advance with a unit cost of -1 to offset the premature calculation cost. If the cell originally contains 0, the unit cost is 1.

      Connect the source node to x[i] with an edge of flow a[i] and cost 0. Connect y[j] to the sink node with an edge of flow b[i] and cost 0. If you understand that flow is “1”, this step will be quite natural.

      Finally, run the maximum flow algorithm. If the flow is equal to sum(a[i]) = sum(b[i]), it indicates that the assignment is valid, and the answer is the minimum cost; otherwise, it is invalid.

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

is rating change delta which shows during contest accurate?

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

How to solve E? Is it related to graphs somehow?

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

    Make a flow network with n+m+2 edges. One is sink, one is source and n vertices for rows and m for columns. Make edges with capacity r[i] to all rows from source and edges of capacity c[j] and cost 0 from columns to sink. Also make edges from row i to column j with capacity 1 and cost 1-a[i][j]. Your answer is minimum cost max flow plus the number of a[i][j] == 1 where the i -> j edge was not taken.

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

E reduces to this CSES problem: Grid Puzzle II

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

I couldn't able to come up with an solution for C problem tried using bit manipulation but got wa on testcase 3 do we have to solve this using any other approach.

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

Speedforces for someone

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

Unbalanced Contest,

A,B,C were too easy and D is too hard.

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

Wrong answer on test 24 in E — Matrix Problem ,, can any one give a test case sorry for my bad English

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

    This test fails

    4 4
    0 0 0 1 
    0 1 1 0 
    0 1 1 0 
    1 1 0 0 
    1 3 1 2 
    2 0 2 3 
    

    Also this

    3 3
    0 0 0 
    1 0 1 
    1 0 0 
    1 1 2 
    1 3 0 
    

    And this

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

D is somewhat monotonic stack and dp, I thought so

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

    I tried the formula dp[i] = Sigma(dp[j-1]) with a[j] >= a[i] and j <= i result is the product dp of 2 sequences a[0] ... . a[minimum_index] and a[n-1] ... a[minimum_index] but wrong, do you have any other solution

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

.

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

D fucking boggled my mind. I thought I had it like, 3 or 4 times, only to fail sample, find out that my method is wrong, come up with new method, rinse and repeat. I wrote everything from monotonic stack to segtree today 🤡

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

knew D was div-conquer with min but couldn't implement 😭

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

How to solve D?

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

What's the idea behind D

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

    DP on suffixes, maintained with a monotonic stack.

    Compute for each index how many arrays you can reach that start with it, ignoring elements before it. You can delete any prefix starting from it that contains no smaller values (the monotonic stack is for this) or delete a prefix immediately after it to reach smaller elements further away. I handled this part with a set but upon further inspection it’s really just a copy of my stack ;)

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

      Could you explain the part "or delete a prefix immediately after it to reach smaller elements further away", it's a bit ambiguous for me.

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

        The first case, where we delete until some index before the next smaller value, does not cover cases where the element immediately after the first one is smaller than it. Consider for example the following case:

        4 3 2 1

        The array 4 2 1 can be obtained by operating on [2, 3], but since 2 comes after the next smaller value after 4, we would not have counted this case. Arrays where the second element is smaller than the first will be obtained by operating on [2, j], if we want the j-th element (smaller than the first) to become the second. And it's only possible if a_j = min(a_2, ..., a_j). So we maintain the set of possible indices j, and remove elements from the set over time.

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

    The problem is quite similar to Indonesian NOI contest here

    I think the approach should be quite similar. Assume $$$dp_i$$$ is the number of ways that the array ends with $$$p_i$$$, then we can consider that for a range $$$(l, r)$$$ we can calculate number of ways when $$$p_l$$$ or $$$p_r$$$ is the minimum

    For each $$$r$$$, there are two possibilities :

    • find conditions for all values $$$l < r$$$ where $$$p_l$$$ is the minimum from $$$(l, r)$$$ then $$$dp_l$$$ is a contributing factor to $$$dp_r$$$

    • find conditions for all values $$$l < r$$$ where $$$p_r$$$ is the minimum from $$$(l, r)$$$. To do this, find an index $$$i$$$ such that $$$i$$$ is the previous smaller element of $$$r$$$. Then $$$dp_{i+1}, dp_{i+2}, ..., dp_{r-1}$$$ are contributing factor of $$$dp_r$$$

    For the first case, we can maintain a monotonic stack and maintain the sum of all dp within the stack

    For the second case, we can use a monotonic stack to maintain previous smaller elements for each index and to find the sum of the dp we can use a prefix sum of dp

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

    you can do it with DnC on the minimums of the array, split the array on the minima and calculate recursively for the left and the right part and merge those results

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

      Which data structure for the splitting would be better than the Linked list or the segment tree?

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

      Can you explain your approach, what would be the base case and the merging condition?

      • »
        »
        »
        »
        5 месяцев назад, # ^ |
        Rev. 3   Проголосовать: нравится +80 Проголосовать: не нравится
        • Solve the problem for the whole array $$$[1, n]$$$. Let $$$m$$$ the position of the minimum. Note that you cannot delete the minimum, and the moves on the left and on the right are independent. So the answer is the product of the answers on $$$[1, m-1]$$$ and $$$[m+1, n]$$$.
        • How to solve for a generic interval $$$[l, r]$$$? Note that you can either keep $$$m$$$ (the position of the minimum value in $$$[l, r]$$$) "alive", or use the elements in positions $$$l-1$$$ and $$$r+1$$$ (if they exist) to delete $$$m$$$.
        • Let $$$a$$$, $$$b$$$ be the answers in the intervals $$$[l, m-1]$$$ and $$$[m+1, r]$$$. In any case, we can keep $$$m$$$ "alive" (in $$$ab$$$ ways). If $$$l \neq 1$$$, we can delete $$$m$$$ (actually, all elements in $$$[l, m]$$$) in $$$b$$$ ways. If $$$r \neq n$$$, we can delete $$$m$$$ (actually, all elements in $$$[m, r]$$$) in $$$a$$$ ways. If both $$$l \neq 1$$$ and $$$r \neq n$$$, we are overcounting the case where we remove every element in $$$[l, r]$$$, so we must subtract $$$1$$$ back.
        • »
          »
          »
          »
          »
          5 месяцев назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          Thanks for such a neat explanation.

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

          Thanks!

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

          Thanks for explaining the approach.

          There is just a correction that:

          If both l≠1 and r≠n, like you said we are overcounting the case where we remove every element in [l,r], therefore we must subtract 1 instead of adding it back.

          ll recur(int l,int r,SparseTable &st,map<ll,int> &map1)
          {
            if(l>r) return 1LL;
            
            int ele=st.query(l,r);
            int m=map1[ele];
          
            ll a=recur(l,m-1,st,map1);
            ll b=recur(m+1,r,st,map1);
          
            ll res=(a*b)%mod;
          
            if(l!=0) res=(res+b)%mod;
            if(r!=n-1) res=(res+a)%mod;
          
            if(l!=0&&r!=n-1) res=(res-1)%mod;
          
            return res; 
          }
          
»
5 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

another speedforces round!

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

I think Problem D is same as this, Except the constraints are tighter.

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

    The hardest step of problem D is to come up with a correct DP. Optimizing it from $$$\mathcal O(n^2)$$$ to $$$\mathcal O(n)$$$ is easy.

    Luckily no one submitted this problem during the contest :(

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

Speedforces lol

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

Easiest D ever seen

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

How to solve E?

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

any hints for D? also can someone try to hack my C?

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

Why C failed at test case 5?237765289 Could anyone point out what i missed ?

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

speedforces moment

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

Today is my birthday, and I wrote this round.lol

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

I have just upsolved problem C and I like it the most!

Thank you guys for the great contest!

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

I think problem F is quite similar to this problem.

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

    Well the proof is not obvious. It only works for set of numbers where all smaller numbers divide each element in the set, for example here it is powers of two. It wouldnt work in cases like {1,3,5}

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

I don't understand why there is such a large gap in difficulty between C and D.

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

if i had an hour more, i can definitely solve D.knew it was some dp and related with monostack stuff.nice problem anyway

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

F has appeared before: coi15p2. And no, it wasn't like the idea coincided or something, this is the exact same problem. I mean, problem-setters could just avoided this by literally search their problem up, but they didn't, which I don't really get.

As a result, an unusual number of consistently low-rated contestants AC F, which are solved by like, what, 30 people, LGM included. A person whose skill are around Expert — Candidate Master level should not be able to pull that off in a 2 hours contest.

If enough people complain about this, the contest could probably get unrated, or... since F is solved by so few people, and these guys solved so few problems that it shouldn't matter. I don't know. Personally, I want the contest to get unrated to punish these MF

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

Very interesting contest, for me problem " C " was super easy even easier than " B " as I love math problems , Thanks for authors <3

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

    Could you share ur intuition for C? C got a lot of ACs . Everybody figured it out so quickly except me

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

      Sure, we know that pow(2,n) it's binary representation is 100.. ( 1 followed by zeroes )

      now for any number X it's binary representation is ones and zeroes for example " 1011 "

      we can write it as 1000 + 10 + 1 which all of them are in the form of pow(2,n) .. So, if we subtract the maximum pow(2,n) less that X form X we will reach to X = 0.

      in this problem we just add one condition that pow(2,n) must be inserted, also we subtract this number from x until it's frequency in the vector or until X become less that it

      // operation 2
      // cnt is temporary freq
      // ar is the freq
      vector<int>cnt = ar;
      cin >> t;
      for(int i = log2(t); i >= 0; --i)
      {
         int mx = pow(2,i);
         if( mx <= t && t && cnt[i])
         {
             // t = constant(k)*mx
             // k musn't exeed cnt[i]
             int k = min(cnt[i],t/mx);
             cnt[i]-=k;
             t -= k*mx;
         }
      }
      

      Wish you got it

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

C got accepted 30 seconds after the contest :(

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

what is the brute force solution for problem-D?

Is it to check for all subarrays something.

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

That problem D was just so hard!!!

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

Hi! How long does it usually take for the editorial to be published? Thank you :)

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

Can someone please hack my C? It's O(n^2) in some cases and I think it should TLE. But I tried the case of 50000 1 0 queries followed by 50000 2 50000 queries and it didn't TLE.

UPD: I resubmit it to judge it on the new test cases and it passes in 1013 ms. So I may have gotten away with it this time. I'll take it as a learning experience.

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

    Seems unhackable. C++ compiler optimization too OP

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

    The complier understand what you are doing with

    while (sum >= p && stock[i]) sum -= p, stock[i]--;

    And convert it to a O(1) operation.

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

      I don't think this is true reading the assembly on godbolt

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

        You are right. I carefully checked the assembly on Compiler Explorer and I can see the loop even on -O2.

        So maybe because everything is in CPU L1 cache so the loop runs super fast.

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

          Yeah. The loop is also very short, the branch predictor is also probably never failing.

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

    currently trying near $$$48000$$$ add queries, and I don't quite know why it isn't getting hacked (or why the setters even set limits too loose)

    seriously what the f
»
5 месяцев назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится
»
5 месяцев назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

why this get so much downvotes?? just for D was too hard?

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

Folks, why in the problem C the greedy approach for the queries of type 2 works? For example, in the normal coin change problem the greedy approach won't work afaik, why here it works? Thank you guys, appreciate!

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

    2^n is greater than the summation of 1+2+4+8+...2^n-1 so you can be greedy about using your smaller powers because they can never contribute to be a bigger one

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

can anyone say why greedy 0-1 knapsack working for problem C, 0-1 greedy knapsack don't work for all denominations right. did there is any special properties of 2 powers that is making greedy knapsack work?if yes what is that prroperty

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

    binary representation of a number?

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

      how it is related, please elaborate. i saw your sol. you are taking maximum possible sum from coins of maximum denomination, like why maximum possible sum from coins of maximum denomination is related to binary representation

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

        so practically when we make the binary representation in base 2 of a number we always take the biggest power of two that is smaller than our number and make that bit 1 and apply the same procedure but for a smaller number, this works because every number has an unique binary representation

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

Uh how does rating work? Will I get rating for this round regardless of my score? Someone explain pls

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

    Yes, you always get a new rating for all contests that are rated for you. This contest is rated for anyone under 2100. Considering that you're currently unrated (that's 0 basically), it IS rated for you.

    Rating works as follows — for any rated contest that you give, your rating is updated based on your performance. If you perform well, it increases, else, it decreases. Anyway, rating is just one factor to competing, in the long run, the experience results in a net positive anyhow. Have fun! :)

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

      Ayo thanks for the reply. Okay so this is a pretty cool system. I did very badly, but eh it's just for fun. It's actually kinda refreshing to compete in programming just for the heck of it.

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

Can anyone suggest me a more optimal solution for C? My Submission

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

Problem C was much easier than i thought TT

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

    What's the worse time complexity of your approach? Isn't it O(m^2)?

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

      It is O(m^2) without compiler optimization.

      The compiler understand the loop

      while(sum+(1<<i)<=x and aux[i]>0 )sum+=(1<<i), aux[i]--;

      and generate a better O(1) code to achieve the same result.

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

        That's cool. I had never known that.

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

        Yes! It's o(m^2) and I've noticed a bit late so i received a hack XD. But I resubmitted with a binary search optimization and got ac too with O(mlogm).

        I'd like to see that O(1) code.

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

          Wasn't aware that your code was hacked. Curious what the test case was. I try using

          100000
          1 0 (repeat 50000 times)
          2 1000000000 (repeat 50000 times)
          

          and it does not work

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

            if you find the test case i would appreciate if share it plz. Also I think of the most obvius test case like that one but no get hacked

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

          What is your binary search approach?

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

            In this line:

            while(sum+(1<<i)<=x and aux[i]>0 )sum+=(1<<i), aux[i]--;

            Instead of adding one by one, do a binary search over lo =0, hi =aux[i] and check if sum+mi*(1<<i) <=x

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

              Alright got it now. Thanks

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

              The binary search can probably be replaced with division.

              $$$desirable$$$ = $$$(sum - x) / (1 « i)$$$

              $$$available$$$ = $$$aux[i]$$$

              $$$taken$$$ = $$$min(desirable, available)$$$

              $$$sum$$$ -= $$$taken * (1 « i)$$$

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

    good one !

    can you explain your approach how the index of element is helping you to construct the ans

    as you stored (element,index) in root , what is the contribution of left ans and right ans

    correct me if Iam wrong

    even I thought of the contribution of minimum index but couldn't proceed:D

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

      for each segment l..r i am getting min value and it's index, let it be (mI). then making a call to its left and right excluding the index. left = l..(mI-1) right = (mI+1)..r

      now, there can be two cases, case 1: when we include element with index mI in our required final array: if that is the case answer is simply leftAns*rightAns.

      case 2: when we don't include element with index mI, this case is difficult in my implementation:

      in this case we have to know whether is there a smaller element than mI on left side and/or right side. thus bools isL and isR

      if isL, then we have to remove all left side including mI, then ans will be added is right side. similarly, left side might be added. note: left side and right side includes empty array also, then there can be case where both isL and isR, then empty would be added twice thus remove isL&isR.

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

    Nice One!

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

Speedforces

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

Plese explain D

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

Can anyone understand the code for problem D of tourist? I can't understand what dp_nxt and dp_sub mean.

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

Honey, I love you too.

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

How to solve Problem C using bitset.

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

Won't we get solutions?

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

Will we get extra rating only by successful hacking or also by submitting correct solutions?

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

Where can I find editorial?

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

Is there a reliable rating predictor available as of today? This one doesn't seem to be working accurately any more.

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

https://codeforces.com/contest/1913/submission/237789418

https://codeforces.com/contest/1913/submission/237900686 The same!!! The first one was hacked The second one was accepted؟؟؟؟؟

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

Hello.Why ratings hasn't come yet?

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

how to solve D ????

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

What about the editorials and rating changes?

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

Can anyone tell when will the rating of this contest release. It's already more than 21hrs...hoping soon.

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

did they forget to update the ratings? Div 3 contest will start soon. How will the ratings be given if they dont update it today lmao.

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

When will this contest rating update and where is the editorial

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

Problem C was terrible for its place.

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

    not gonna lie, I couldnt solve it in the contest cuz i overcomplicated it but once i saw the correct idea, the code was easy af.

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

Please add the editorials.

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

Since no tutorials have been provided yet (as well as my rating change), here are my short hints of problems D, E, F.

Hint of problem D
Hint of problem E
Hint of problem F
»
5 месяцев назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

Anybody mind taking a look at my C and giving some insights as to why it is incorrect? After looking at the test case, it seems that there is an iterator position for a map that is before begin, but I do not know how to properly handle that case. Link to code 237787623

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

When will the rating of this round be updated? I was hoping to become specialist and then give today's div3 as a rated round.

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

40 min left for next contest to begin and no change in ratings so far. Uneasy situation.

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

Problem C

Hey can anyone tell the error in this solution 237781165. I am getting runtime error.

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

    I managed to pin point the issue.

    You can see these two submissions:

    238078175 Accepted

    238078130 Runtime error on test 3

    The only difference is that the loop variable i being int or long long

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

    I think I figure this out.

    The issue of your code is that, when you vector v has no element, i.e. for type 2 query, b is 0, v.size() is 0 and v.size() - 1 should be -1.

    However, v.size() actually returns unsigned integer, so v.size() - 1 becomes really big (underflow) and it pass the for loop condition i >= 0. Then accessing v[i] will cause a segmentaion fault.

    I am not sure why this doesn't happen to test1 and test2 though,

    To solve this bug, you can simply push back a 0 to the vector v to make sure that underflow never happened. See 238078855 for added lines.

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

Why are the ratings not out yet?

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

    There is an announcement telling that ratings will be updated after the div.3 contest due to technical reasons. See div.3 post for reference

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

Please upload the editorial and new ratings. Also, please try to elaborate on the concepts used instead of the method.

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

Is the contest unrated?

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

Здравствуйте, уважаемая поддержка codeforces! Недавно мне пришло сообщение о том, что мое решение задачи С и В совпадают с решениями тех же задач у MIKHAIL2006 (Round 915, div2). Дело в том, что я сейчас нахожусь в другой стране и писал этот раунд не со своего компьютера и в первый раз, поэтому я сначала защел на свой старый аккаунт MIKHAIL2006 (перепутать их очень просто, логин отличается на 1 символ, а пароли одинаковы) и решил там задачи А, В и С. После этого я заметил, что писал раунд не с основного аккаунта, скопировал решения и отослал их с этого, основного аккаунта. Именно поэтому мой код в точности совпадает с решениями MIKHAIL2006, а так же время посылки на MIKHAIL2007 для всех 3 задач было одинаково. Я понимаю, что это моя ошибка, но я хочу, чтобы было понятно, что решения этих 3 задач не были списаны с кого-либо, я просто заслал их с двух своих аккаунтов (можно посмотреть на IP адреса вхождений на сайт этих двух аккаунтов, он будет один и тот же). Заранее спасибо за понимание.

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

Attention!

I received the following message from system: Your solution 237799004 for the problem 1913B significantly coincides with solutions mayank246/237799004, Naytive_Ritninja/237800400. Such a coincidence is a clear rules violation. Note that unintentional leakage is also a violation. For example, do not use ideone.com with the default settings (public access to your code). If you have conclusive evidence that a coincidence has occurred due to the use of a common source published before the competition, write a comment to post about the round with all the details. More information can be found at http://codeforces.com/blog/entry/8790. Such violation of the rules may be the reason for blocking your account or other penalties. In case of repeated violations, your account may be blocked.

As that was the approach used by most of the candidates and the candidate is unknown to me. It's just a matter of coincidence that my code matches with other person. Kindly review it. and give me my rating back. BledDest

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

I got a codeforces system message that my solution for problem C coincides with other people, but I haven't done anything and it is a sheer coincidence that my code matches with others, please give my rating back.

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

I am sorry for my mistake, before the contest that day I had mistakenly logged into my old (SAZIBUR)account. I mistakenly submitted the solution to the contest without logout of that account before the contest. So later when I see it's my old account so I logout it then change some code and submit with my main account. And rest of the time I complete this contest with my main(Sazib204061) account. I apologize for my mistake. I promise I won't make this mistake again. So please don't block my account.

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

My solution to Problem A was rejected in the hacking round. Where was the problem?

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

Wait what.

I thought it was rated for Div.2
»
4 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

What the difference between "Edufcatinal" with nomal?

Is it easier or it have more rules?