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

Привет, Codeforces!

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

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

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

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

Задачи вместе со мной придумывали и готовили Адилбек adedalic Далабаев, Иван BledDest Андросов, Максим Neon Мещеряков, Артем Ferume Иликаев, Руслан AcidWrongGod Капралов, Алексей ashmelev Шмелев, Александр fcspartakm Фролов, Дмитрий DmitryKlenov Кленов, Дмитрий dmitryme Мещеряков и Елена elena Рогачева. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

Обратите внимание, что данный раунд частично пересекается по задачам с Чемпионатом Юга и Поволжья России. Если вы участвовали в данном соревновании, то, пожалуйста, воздержитесь от участия в раунде.

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

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

Harbour.Space
НОВАЯ ВОЗМОЖНОСТЬ ОБУЧЕНИЯ И РАБОТЫ В БАРСЕЛОНЕ — BIMBA Y LOLA x HARBOUR.SPACE UNIVERSITY

Harbour.Space University в партнерстве с BIMBA Y LOLA предлагают стипендию для получения степени магистра в сфере Computer Science, а так же опыт работы в качестве Junior Java Developer в команде разработки BIMBA y LOLA.

В BIMBA Y LOLA понимают важность работы с самыми креативными профессионалами, с предприимчивым духом и страстью к своей работе. Их соблазняет талант, сопереживание, инициативность, аналитический характер, приверженность качеству, проницательность и любовь к деталям. И, конечно же, явное призвание к моде.

Если вы разделяете эти ценности, то мы предлагаем вам молодую, динамичную и стимулирующую среду, в которой вы сможете развиваться профессионально; компанию, реализующую амбициозный международный план расширения и уже присутствующую более чем в 18 странах.

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

Требования:

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

Кандидат должен быть знаком с:

  • Agile Methodologies (scrum)
  • GIT
  • Java 8/11+
  • Spring
  • Maven
  • JUnit
  • Mockito
  • UML
  • HTML
  • CSS
  • Javascript
  • ReactJS
  • SQL Server/MySQL

Желательные навыки:

  • Azure
  • Azure DevOps — Pipelines
  • Docker
  • Kubernetes
  • Helm
  • Jira
  • Confluence

Итого:

  • 100% стипендия для получения степени магистра в области Computer Science в течение одного года.
  • 4 часа/день стажировки в кампусе.
  • Конкурентное вознаграждение.
  • Возможность присоединиться к компании полную ставку после окончания обучения.
  • Пожалуйста, обратите внимание, что заранее отобранные кандидаты должны будут заплатить невозмещаемый вступительный взнос в размере 125€ за оценку.

Обязательства кандидата:

  • Обучение: 4 часа/день
  • ‍Вы завершите 15 модулей (длительность каждого 3 недели).
  • Ежедневная учебная нагрузка составляет 3 часа, плюс домашнее задание, которое нужно выполнить в свободное время.
  • Работа: 4+ часа/день

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

Подать заявку →

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

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

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

My comment is on top.... Can't believe this.. By the way thanks to authors for their hard work <3..

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

My comment is on top (yeee) ... By the way thanks to authors for their hard work <3... Hope we'll enjoy the round.

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

Educational round....ok(finger crossed)

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

Wow, So exciting to see this round, I hope it will be interesting <3.

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

Wow, So exciting to see this round, I hope it will be interesting <3.

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

Nothing scares me more than edu round.

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

Why has the frequency of edu rounds decreased?

Not complaining, just curious!

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

The problems were invented and prepared by Adilbek adedalic Dalabaev, Ivan BledDest Androsov, Maksim Neon Mescheryakov, Artem Ferume Ilikaev, Ruslan AcidWrongGod Kapralov, Alexey I_Remember_Olya_ashmelev Shmelev, Alex fcspartakm Frolov, Dmitry DmitryKlenov Klenov, Dmitry dmitryme Mescheryakov, Elena elena Rogacheva and me.

I think the writer list on the Contest page doesn't reflect this correctly, it's currently just the usual BledDest-Neon-Roms-adedalic-awoo.

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

is it rated?

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

Educational Rounds are mathforces af. Would skip this one.

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

I hope, inshallah! I will learn something new from this contest.

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

edu rounds always bring me fear

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

Hoping for the final +14 for purple!

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

GL everyone

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

Damn that Problem C is a good one. (T_T)

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

Another great problem C in educational round.

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

    I got TLE! Created 5 arrays according to string sizes.
    Accordingly, there will be 4 pairs that produce even sums ((1, 3), (1, 5), (2, 4), (3, 5)).
    Also, count among themselves meaning among array of length 1, 2, 3, 4, and 5.
    Got TLE for this!

    Any leads how to solve it?

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

      1) We can observe that two strings i,j will be lucky only if their parity is same since we want even length ticket.

      2) So we can solve separately for odd (1,3,5) and even (2,4) since max length is 5 only. Now we just need to see among even and odd, let me consider even case. The combinations possible are 2+2, 2+4, 4+2, 4+4.

      3) Since we want both halves to have same value, for 2+2 and 4+4 case, we will simply use map to store strings with same value and add it to answer. For example if there 3 strings of length 2 with value as 5 (maybe 23,14,32 etc...), then for each we will add 3 since we can concatenate to itself. This case will be same for 1+1,3+3,5+5.

      4) Now for special cases like 2+4, 4+2 we just need to check what is the relation for example in 2+4 case, let ticket be ab+cdef. We want a+b+c = d+e+f, which is same as a+b = d+e+f-c. So we for every 2 length string we will add number of 4 length strings whose d+e+f-c = value of current 2 length string.

      5) You can consider different cases like this for example in 3+5 case we want number of 5 length strings such that their last 4 — first digit = value of 3 length string.

      Hope this helps

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

E's statement is worse. Furthermore, it would be helpful to have an example or explanation provided for the problem

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

implementationforces

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

D is goated

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

How to solve D?

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

How to solve C?

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

Today's D problem is easy if you remember this problem exists

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

How to choose $$$b_0$$$ in D? Any observations, brute force approaches?

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

    Hint — You have to choose each bit of b0 independently.

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

    Determine if each bit of b0 should be 1 or 0 by comparing with how many 1s should exist in the final array.

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

    First initalize it with 0, and caluclate every $$$b_i$$$. Notice now that if you flip a bit in $$$b_0$$$ for ever $$$b_i$$$ that bit flips as well. We can precalculate the number of apperences for each bit in the solution of correct $$$b$$$. Now we can simply compare the occurences of bits in our current solution and the number of bits in the correct solution. If they are the same we do nothing, else we flip.

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

    From b[i]^b[i+1] = a[i], we can deduce b[i] = b[1]^a[1]^a[2]^...a[i-1]. Since, the answer always exists all prefixes a[1], a[1]^a[2], ..., a[1]^a[2]^a[3]^...a[n-1], will be unique. So just fix b[1] and check for maximum and minimum XOR

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

    Most likely people will tell you a solution which considers each bit separately (it is easier to code), but when this problem was proposed, I solved it in a different way

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

      I mean, you can just bruteforce for all values of $$$b_1$$$ in $$$[0,n)$$$ and output the one where $$$max=n-1$$$ and $$$min=0$$$, right? That should be trivial using a binary trie storing all prefix XORs.

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

      How does solving each bit independently gives correct answer? We also need to ensure that those bits need to appear in correct combination with each other. For example,(in bits), 000, 001, 010,011,100. And 000, 001, 010, 000, 111. Both have same frequency of each bit but they occur at different positions.

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

        If some bit $$$x$$$ has the same frequency of $$$0$$$'s and $$$1$$$'s in the resulting sequence no matter how you choose it in the starting element, then it means that $$$n$$$ is divisible by $$$2^{x+1}$$$; and if we flip it, every number in the sequence just transforms from $$$b_i$$$ to $$$b_i \oplus 2^{x}$$$, which is a bijection when $$$n$$$ is divisible by $$$2^{x+1}$$$.

        So, any such bits in the answer can be flipped without breaking anything.

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

          My question is different. You are answering when frequency of a bit x is same in a set of numbers. My question is: There can exist 2 sets of numbers where frequency of each bit in the two sets are same but the sets are not same. S1 = {00,01,11}, S2 = {10, 01, 01}.

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

        That's how I reason about it:

        For $$$i$$$-th bit of $$$b_1$$$, the necessary condition is that $$$b_1, b_1 \oplus b_2, b_1 \oplus b_3, ..., b_1 \oplus b_n$$$ has the same number of set bits as sequence $$$0, 1, ..., n - 1$$$.

        The only way for this condition to not be sufficient is if setting any bit for $$$b_1$$$ works.

        That can only happen when there are initially more 1 bits in sequence than 0 bits (specifically there is one more 1 bit), which can't happen due to the nature of $$$0, 1, ..., n - 1$$$ sequence (at any n, number of 1 bits is not greater than number of 0 bits)

        EDIT: i wrote some bullshit. Setting any $$$i$$$-th bit in $$$b_1$$$ works, if n is divisible by the $$$2^{i + 1}$$$, and it doesn't affect the answer, because there's always pair $$$(x, y)$$$ in $$$0, 1, ..., n - 1$$$, such that $$$x \oplus y = 2^{i}$$$

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

      Considering each bit separately is also much easier to reason about, because the condition "every prefix xor of $$$a$$$ should have same number of set bits as sequence $$$0, 1, ..., n - 1$$$" is sufficient and quite natural to get across

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

      how we ensure that the elements of the array will be unique?

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

        for a solution $$$x_0$$$, if the resulting array has any $$$i,j$$$ such that $$$(x_0 \oplus c_i)=(x_0 \oplus c_j)$$$, then $$$c_i = c_j$$$, which means for any value of $$$x$$$, $$$(x \oplus c_i)=(x \oplus c_j)$$$, therefore there won't be any solution at all, which contradicts the constraint in the problem.

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

      I was very close to what you was thinking but instead of thinking to store in binary tree I think that this may be done by greedily

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

Why should problems like C appear in CF?

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

good contest

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

https://codeforces.me/contest/1895/submission/231204890 , Can anyone tell me why I am getting TLE , Sorry I am just dumb !

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

I like problem C, even though I have not solved it because I had overcomplicated implementation.

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

Can anyone hack this? I did a randomized solution to D:

https://codeforces.me/contest/1895/submission/231206864

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

Cannot find a good solution for D and bashed trie.

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

I'm not sure if this problem https://leetcode.com/problems/decode-xored-permutation/ is like today's problem D. These two questions are too similar. I think some people may have just modified the code a bit and moved it over, but I believe everyone wouldn't do that.

But this really affects my mood. In fact, I was looking for the problem for almost half an hour and I finally found it when the contest has finished for 30 seconds. Hope I will see every problem next round new, not existing.

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

Is there any way to actually calculate b[0] in problem D ? I tried to compute XORs from 0 throught n-1, and it is equal to XORs of all prefixes ^(n times) b[0] . But sadly it doesn't help when n is even.

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

    I don't exactly know why your solution is correct for odd $$$n$$$, the way I found $$$b[0]$$$ is first to find the prefix XOR of the array $$$a$$$. Then count the number of occurrences of each bit in the prefix XOR array. Compare it with the number of occurrences of each bit from $$$0$$$ to $$$n - 1$$$.

    The bits whose number of occurrences is not equal should be in $$$b[0]$$$. (We can see that if the number of occurrences of some $$$i$$$-th bit is $$$k$$$, then choosing that bit in $$$b[0]$$$ will change its number of occurrences to $$$n - k$$$.)

    The remaining numbers can be calculated easily.

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

for G, splay tree: TLE Red black tree: AC(500ms)

don't know why :(

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

Two solutions that look similar 231191280 231185745

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

How can I solve F?

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

    Count number of arrays with minimum element $$$ \lt x+k$$$ then subtract out number of arrays with max element $$$ \lt x$$$. To do first part consider the number of difference arrays on $$$n$$$ elements, $$$(2k+1)^{n-1}$$$ then consider that you can shift the array up/down to decide where the minimum element will be with $$$x+k$$$ options. To find what we need to subtract out I did matrix expo.

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

    Let an array $$$a$$$ be good if

    • $$$a_i \ge 0$$$ and
    • $$$|a_i - a_{i-1}| \le k$$$

    Now the answer is equal to (the number of good arrays that contain an integer in range $$$[0, x+k)$$$) minus (the number of good arrays that only contain integers in range $$$[0, x)$$$).

    The number of good arrays that contain an integer in range $$$[0, x+k)$$$ is equal to $$$(x + k) \cdot (2k + 1)^{n-1}$$$

    Proof:

    The number of good arrays that only contain integers in range $$$[0, x)$$$ can be calculated with fast matrix exponentiation:

    Let $$$A[n]$$$ be an $$$x \times 1$$$ matrix where $$$A[n]_i$$$ is equal to the number of good arrays of length $$$n$$$ that only contain integers in range $$$[0, x)$$$ with final element equal to $$$i$$$.

    The number we want to calculate is $$$A[n]_0 + A[n]_1 + \dots + A[n]_{x-1}$$$.

    Clearly, $$$A[1]_0 = A[1]_1 = \dots = A[1]_{x-1} = 1$$$.

    Let $$$M$$$ an $$$x \times x$$$ matrix: $$$M_{ij} = 1$$$ exactly when $$$|i - j| \le k$$$.

    We can notice that $$$A[i+1] = MA[i]$$$. This means that $$$A[n] = M^{n-1}A[1]$$$.

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

      Thnak u so much for your detailed explanation!

      But how can you come up with that? I just cannot think of this bijection myself.

      Is there some basic logics under it or any problems similar to this problem?

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

      I have another way to argue why the number of good arrays contain a element in $$$[0, x + k)$$$ is $$$(x + k)(2k + 1)^{n - 1}$$$.

      consider fixing the difference array of $$$a$$$, clearly there are $$$(2k + 1)^{n - 1}$$$ ways to do this, then for each difference array, we can add the whole array with any integer(that is, translate the array horizontally), and let focus on the minimum of this array, clearly it must be no less than $$$0$$$ and less than $$$x + k$$$ to be a good array, so for a difference array, there are $$$(x + k)$$$ ways to do that, thus the number of good array is $$$(x + k)(2k + 1)^{n - 1}$$$.

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

[ Deleted ]

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

Is there a case for D where the elements in the answer array can satisfy all the XOR properties, and whose sum is equal to the sum of [0, n-1], but is not correct? As in some elements might have duplicates and the max element can exceed n-1. My solution goes over the 2^19 ways to either set the ith bit in the first element on and off for each of the 19 bits. Then I just check the total sum in o(1) time for all of these ways to see if it matches the intended sum.

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

    Such a counterexample is not possible. The fact that a solution exists guarantees that all arrays you can generate consistent with A have distinct elements. There is only 1 possible sequence of N distinct integers that has the same sum as 0+1+2+..+N-1, so your solution works.

    You can prove this more formally by noticing that given A, the generated sequence B is determined entirely by the choice of the initial element B[0]. More formally, we can define B(n) as the candidate sequence B that starts with n:

    B(n)[0] = n
    B(n)[i] = B[i - 1] ^ A[i - 1] = n ^ A[0] ^ A[1] ^ .. ^ A[i -1]  (1 ≤ i < N)
    

    Then it's clear that B(x)[i] = B(0)[i] ^ x, and therefore B(y)[i] = B(x)[i] ^ (x ^ y).

    It follows that if there is any value of x such all elements of B(x) are distinct (which the problem guarantees), then for all x, all values of B(x) must be distinct, because you can't make two distinct value equal by XOR'ing them with the same constant.

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

Why did the problemsetters use setTestCase in the validators for single-test problems C and D (and also in some other problem recently)? Samples look ugly, and the use of this function here is pointless.

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

Ideas
A There can be two cases 1. When x >= y In this case we can just move along the path and pick the key until we reach the chest. 2. When x < y In this case we can greedily pick the chest when we see it until k + x <= y Then we can traverse the leftover distance twice to reach the chest again. So basically min(k + x, y) + 2 * (y - min(k + x, y))
B To get the min path just sort the array choose first N points as X coordinates of each pair Choose the next N points as Y coordinates.

C A thing to notice is that O + O = E & E + E = E. Keeping this in mind the only way we can get even lengths are := 1 + 1, 1 + 3, 3 + 1, 1 + 5, 5 + 1, 2 + 2, 2 + 4, 4 + 2 To find these pairs fast you can notice for the S(s(1) + s(3)) the sum S[0,1] is nothing but s(1) + s(3)(0) and for S(s(3) + s(1)) the second sum is s(3)(2) + s(1). Similarly form these formulas for all other pairs and store each unique sum is 5 seperate maps (Since size of string is atmost 5).

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

awoo For Question D of today's contest, my submission had wrong answer on test 2, Test 2 was part of the samples, but still I got penalty for submitting a code that gave a wrong answer on samples, please look into it

Thank you

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

Took too much time to solve C :(

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

In Problem E, is the card returned to the hand of the player who beat the opponent's card?

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

Can anyone please explain C?

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

    Each combined ticket consists of two snippets ("snippets" meaning strings in the input). There are three possible cases:

    1. The two snippets are equal length, e.g. "123" + "222" = "123222" ($$$1+2+3 = 6 = 2+2+2$$$).
    2. The left snippet is longer than the right, e.g. "1234" + "11" = "123411" ($$$1+2+3=6=4+1+1$$$).
    3. The right snippet is longer than the left, e.g. "26" + "1234" = "261234" ($$$2+6+1 = 9 = 2 + 3 + 4$$$).

    Define count(len, sum) as the number of snippets in the input that have length len and the sum of the digits is sum. It's easy to precalculate and store these in an array count[6][46] or something (since length is limited to 5, and therefore sum of digits is limited to 45).

    Now for each snippet, consider how many of each of the three cases you can generate.

    For case 1, a snippet s with length l and sum s can appear on the left side exactly count(l, s) times (i.e., it can be paired with each snippet [including itself!] that has the same length and digit sum). That's the easy case. (You might ask: what about when s appears on the right side? Ignore that case to avoid double counting.)

    For case 2, a prefix of s of length k will be the first half, and the remaining digits will be part of the right half. So for example, if we have s="1234567" which has length 7, we can construct tickets "123456|7abcde" or "12345|67abc" or "1234|567a" (where '|' marks the middle). Consider the first one: "123456|7abcde". Here, the left side has sum 1+2+3+4+5+6 = 15, so the right side must have the same sum. The right side already has a 7, so the remaining 5 digits (*abcde*) must have sum 15-7=8. So the number of tickets of the form "123456|7abcde" is count(12-7, 1+2+3+4+5+6-7). Similarly, the number of tickets of the form "12345|67abc" = count(10-7, (1+2+3+4+5)-(6+7)) You can generalize this to something like: $$$count(|s| - k, \sum s_{1..k} - \sum s_{k..|s|})$$$ for all $$$|s|/2 \lt k \lt |s|$$$.

    Case 3 is exactly the same as case 2 but using suffixes instead of prefixes.

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

this contest proved how bad i am at implementation.

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

Can someone provide test cases for problem C? I'm struggling to come up with good ones to test my code. Thank you.1895C - Torn Lucky Ticket 231207578

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

Was anyone able to pass a randomized solution for problem D?

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

how to solve C?i have no idea? need help

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

How to solve F?

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

In the question D of this contest, when can ai be equals to 2*n.

Is it even possible, If yes then the case??

As max value of A^B is A+B but not for A==B. Please help

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

why am i still unrated for this contest?

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

What happened on problem E? Why are there many judgement failed?

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

What's wrong with problem E?

Everyone got Judgement failed in system test.

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

now it is showing the contest but no change in rating.

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

problem can easily be solved by https://www.geeksforgeeks.org/find-maximum-xor-given-integer-stream-integers/ and i read some comments saying that it was like another problems i think thats not ok that problems repeated

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

    I think D is not repeated because the main focus of this question is to transform it into "find the max after xor given integer". It is easy to solve the latter lol.

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

    The reduction to this basic 01trie trick requires some non-obvious steps, such as taking the prefix sum, then proving that the prefix sum must be unique, and finally reducing it to the condition of max XOR-sum $$$\leq n-1$$$. And also that problem on leetcode only involves the case where $$$n$$$ is odd, which is trivial and imo does not provide additional insight to the even case.

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

Why are they not judging E? Did someone TLE/RE Hacked the main solution or smth?

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

Is the educational round unrated? The rating is still not updated..... It's my first educational round.... Someone please tell me

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

Isn't it a bit late for not putting Editorial?

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

Why not release full 5-hour version of a regional contest? What's the point in spoiling half of the problems?

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

For F,why can (k — x + 1) be more than n.The situation doesn't follow condition 1.

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

MikeMirzayanov and awoo, User ALL_LOWERCASED, Sir-Ahmed-Imran and I got the solution of the problem D skipped because of similarities. But the code of the Trie which was common was taken from this website, the code which we used is at the bottom of the page.The code was available before the contest.