Блог пользователя Ormlis

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

Спасибо за участие!

1834A - Единичный массив придумал и подготовил Artyom123

1834B - Максимальная прочность придумало Жюри олимпиады, а подготовил TheEvilBird

1834C - Игра с переворотом придумал и подготовил sevlll777

1834D - Опрос на уроке придумал vaaven и Mikhango, а подготовил Alexdat2000

1834E - MEX НОК придумал TeaTime, а подготовил teraqqq

1834F - Печатная машинка придумал и подготовил Ziware

Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Разбор задач Codeforces Round 879 (Div. 2)
  • Проголосовать: нравится
  • +186
  • Проголосовать: не нравится

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

Fast editorial!

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

[Deleted]

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

That was quick

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

Fast editorial!

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

Great contest. Good problems!

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

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

Fast editorial!

It's a pity that I didn't manage to solve D, by the way.

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

[user:Ormilis] Please add a case with 1e5 elements 2,3,2,3,2,3,...... in problem E. Many solutions are accepted which will run in O(n^2) for this test case since lcm will never exceed its limit and no multiple of lcm is present in this case.

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

I made Video Solutions for A-E.

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

This seems to be unintended $$$O(n \log n \log^2 {10}^7)$$$: 210082970

I'm actually surprised there were no strong tests like $$$a_i = 2^{\frac{i}{\tt{const}}}$$$.

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

For C look at my solution

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

For the C solution

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

can not understand why the answer of question E is no more than 1e9, any strict proofs?

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

    In order to have $$$lcm$$$ be equal to a prime number we must have it in the array. So we only have $$$n$$$ places for prime numbers, that means we cannot ever get $$$n+1$$$ th prime number which is $$$4256249$$$. So we can bound it at that number also.

    Because of the prime fact you can also say that $$$1e9+7$$$ will never be included, because $$$a_i\le1e9$$$ and $$$1e9+7$$$ is prime so you cannot put it into the array.

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

Hope source code.

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

Can anyone tell me what is wrong in this solution for problem D? 210103552

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

    In your approach it is not necessary that p1 is the interval with minimum right, for example intervals are- (1,10) (1,8) (2,3) here minimum right is (2,3) interval

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

in E, the answer is upper-bounded by the (n + 1)th prime

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

Can anyone tell how to efficiently find the segment which has the shortest length and lies completely inside a given segment in problem D.

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

    Just find the overall shortest segment and assume it lies inside the segment you are checking -> If not, you will check the outer segments anyway, so it won't change the answer.

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

      I can do it by segment tree?? but is there any other method ??

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

        To find the overall shortest segment? It should be just a simple iteration through all segments. Something like the following:

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

        hope this helps comment-1047413

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

    I have figured it out why simply check the overall shortest segment works:

    Let's pick up a segment A, and find another segment B which shares the shortest common subsegment with A.

    If the shortest segment lies out A, it will share 0 element with A, we can simply choose it, because this will be the optimal choice. When the shortest intersect the beginning or the ending, we can tell that any segment completely lies in A will not product a better answer, because any other segment inside A shares no less than the length of the shortest.

    If the shortest lies completely in A, you should check if there are other better choices by check the segment have the largest ending and the one with smallest beginning.

    So there is need to find such a segment you are looking for.

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

Почему в задаче С, s сводится только к t или rev(t), разве не может быть случая когда стоит взять некоторые символы из s другие из t чтобы в итоге получился палидром и точно не потребовалось ждать ещё одного реверса от Боба?

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

I am a newbie. I just participated and solved problem A and it got an accepted verdict. After solving problem A, I left the contest. I just noticed that I have got a -18 score. Are there cases where even if you solved the problem but you got a negative score? Is it just because I solved it late or because I solved only one problem? How are generally contests assess the solved problems? Thanks for the clarification in advance.

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

    You get score based on your ranking in the contest and your rating. Basically if you perform better than would be expected of someone with your rating, your rating will increase and if you perform worse, your rating will drop

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

      So scoring does not solely depend on how many problems you solved or when you solved them, right?

      So let's say someone with a rating of 3200 solves problems A and B correctly in division 2 in the early minutes of the contests. Despite that, He/She will get less score or even a negative score. Did I understand it correctly? I appreciated your response.

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

B is very Bad !

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

Hello everyone In problem 1834B - Maximum Strength i am not able to understand the part where it is written like "Now we can represent the numbers L and R as their longest common prefix" can anybody help me ?

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

    The editorial says that the numbers L (after padding with zeroes) and R can be represented in three parts. The first part is the longest common prefix, the second part is the index where L and R differ for the first time and the third part is the remaining string.

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

    If you're given for example

    $$$ L = \color{red}{12345}\color{blue}{6}\color{green}{2718281}, $$$

    and

    $$$ R = \color{red}{12345}\color{blue}{8}\color{green}{0123456}, $$$

    we see that the red part (the longest common prefix) contributes $$$0$$$, the blue part (the first digit where $$$L$$$ and $$$R$$$ differ) contributes at most $$$8-6=2$$$, and for the green part (the rest), we can pick $$$9999999$$$ for $$$L$$$ and $$$0000000$$$ for $$$R$$$ (because whatever you set, the blue part ensures the first number is already smaller than the second). Thus the answer is always

    $$$ \text{difference of blue digit} + 9\times \text{length of green part}. $$$
»
11 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In D in the fourth testcase suppose I ask first student questions 2,3,4,5 so his hand is at -4 and I ask student 2 question 1, so his hand is at -1 and hand of third is at 0, so the answer should be 4??

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

Is the 4th tc of D wrong, as suppose I ask stud1 ques 2,3,4,5 so his hand is at -4 and I ask stud2 ques 1 so his hand is at -1 and the hand of stud3 is at 0 so the answer should be 4 right??

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

    You're supposed to ask the same questions to all students, so if you ask questions 2,3,4,5.

    Student 1 gets a score -4

    Student 2,3 get a score of -2.

    Hence difference is 2 in this case.

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

good contest_

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

in B

when 9 189 answer is 19, why? TheEvilBird

I think answer is 18, by using 9 and 90

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

    Take $$$100$$$ and $$$99$$$ and you will get $$$|1 - 0| + |0 - 9| + |0 - 9| = 1 + 9 + 9 = 19$$$.

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

can problem B be solved using digit dp?

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

Amazing round! Enjoyed the problems a lot.

I think test cases maybe weak for problem $$$E$$$, I have two almost identical solutions where one is getting AC in ~0.7s and the other is getting AC in ~1.5s

My solution is the same as the editorial but I perform the actions in a slower (dumber) way. My algorithm is as follows:

  • Set $$$lim = 10^7$$$ as the upper bound and ignore all LCMs greater than this.
  • I make a segment tree on the array with LCM as combine operation.
  • Iterate over $$$r$$$ and find all the first $$$l$$$'s such that $$$LCM(A[l..r])$$$ is unique.
  • To do this we first set $$$l=r$$$ and find the minimum $$$l'$$$ value such that $$$LCM(A[l..r]) \neq LCM(A[l'..r])$$$ using the segment tree trick.
  • Set $$$l = l'$$$ and repeat above until we cannot find $$$l'$$$ for a particular $$$l$$$.
  • Add all these values to a set and find mex.

I think time complexity is $$$O(N \log N \log 10^7)$$$

The other nearly identical solution that is slow is, Instead of iterating over $$$r$$$, I iterate over $$$l$$$ and perform the equivalent actions.

without #define int long long
Soln1 submission: 210273930 AC with 0.7s
Soln2 submission: 210273834 AC with 1.5s

with #define int long long
Soln1 submission: 210271657 AC with 1.6s (hackable)
Soln2 submission: 210271736 TLE

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

In problem B

Let's say L = 68 and R = 72 according to the editorial ans = abs(6 -7) + 9 = 10 But is 10 possible?

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

anyone managed to solve E with sparse table?

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

For E, would we also need to consider an extra O(log(M)) complexity for lcm operation?

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

cool

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

C was a nice problem indeed, and its explanation in the editorial is great as well. good job Authors!!

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

My $$$O(nlog^2a_ilogn)$$$ for problem E passed. 232426932

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

I think there was a typo in problem E's editorial: $$$n^2 \ge x^2 \ge 2^{k - 1}$$$ which is actually: $$$n^2 \ge x \ge 2^{k - 1}$$$.