Блог пользователя wakanda-forever

Автор wakanda-forever, 7 дней назад, По-английски

Thanks for participating. We hope you liked the problems and enjoyed the round.

[problem:2226A]

Idea: wakanda-forever
Preparation: wakanda-forever
Solution: wakanda-forever

Solution
Implementation
Rate The Problem!

[problem:2226B]

Idea: wakanda-forever
Preparation: wakanda-forever
Solution: wakanda-forever

Solution
Implementation
Rate The Problem!

[problem:2226C]

Idea: wakanda-forever
Preparation: wakanda-forever
Solution: wakanda-forever

Solution
Implementation
Rate The Problem!

[problem:2226D]

Idea: wakanda-forever
Preparation: wakanda-forever
Solution: wakanda-forever

Solution
Implementation
Rate The Problem!

[problem:2226E]

Huge thanks to chromate00 for suggesting this task.
Preparation: wakanda-forever
Solution: Proof_by_QED

Solution
Implementation
Rate The Problem!

[problem:2226F]

Idea: wuhudsm
Preparation: wuhudsm, wakanda-forever
Solution: wakanda-forever

Solution
Implementation
Rate The Problem!

[problem:2226G]

Idea: wuhudsm
Preparation: wuhudsm, wakanda-forever
Solution: wuhudsm

Solution
Implementation
Rate The Problem!
Разбор задач Codeforces Round 1095 (Div. 2)
  • Проголосовать: нравится
  • +16
  • Проголосовать: не нравится

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

first. $$$B$$$ is a great segtree problem

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

    You mean $$$E$$$?

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

      No, for $$$B$$$ you can notice that if you fix an index $$$i$$$ in the array, then for any $$$j \ge i$$$ the value of $$$[\max(arr[i..j]) - \min(arr[i..j])] - \gcd(arr[i..j])$$$ is monotonic (it only increases as $$$j$$$ increases). That's because, whenever you add an element, the $$$\gcd$$$ can only decrease and the $$$\max - \min$$$ can only increase.

      So since the property is monotonic, you can maintain two sliding windows $$$i..j$$$ and $$$i..k$$$ where $$$i..j$$$ represents the range of endpoints $$$i \le e_1 \le j$$$ to $$$i$$$ such that $$$[\max(arr[i..e_1]) - \min(arr[i..e_1])] - \gcd(arr[i..e_1]) \le 0$$$ and $$$i..k$$$ represents the range of endpoints $$$i \le e_2 \le k$$$ such that $$$[\max(arr[i..e_2]) - \min(arr[i..e_2])] - \gcd(arr[i..e_2]) \lt 0$$$. And the answer for an $$$i$$$ is just $$$j - k$$$.

      To easily query the $$$\max, \min, \gcd$$$ of a subarray, you can use a segment tree or a sparse table.

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

        checking adjacent values is enough ig, you can never have a subarray of length three or more which satisfies the properties.

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

Cannot be on the same page as the author in 2226D - Reserved Reversals

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

Was doing exactly the same stuff for C, but wasn't convinced with any greedy approach that came to mind.

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

D's so hard :(

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

that C was great, I tunnel visioned on the wrong greedy

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

I am doing the exact same thing for C as in the editorial 372865973. Where am I going wrong?

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

problem C is awesome

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

E reminded me of https://cses.fi/problemset/task/2425, was close to solving it :(

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

Fun fact: F can be done in $$$O(\sqrt n)$$$

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

For Problem E, I started thinking about going from smallest prefix to the longest but concluded it was not feasible under the time limit. Then it hit me to go from largest prefix to smallest. pretty amazing problem imo.

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

Screencast with commentary : Could only solve A and B. Had the correct idea for C, but had some bugs in implementation.

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

I imagine that some people tried an increasing greedy instead of a decreasing greedy for C. This does work but the solution is less clean. The idea is still to binary search on a valid $$$m$$$. We check if the first $$$m-1$$$ elements can be filled. For a given $$$m$$$, we can do the following:

Create a $$$cnt$$$ array, and maintain an unresolved left bound $$$L$$$ and right bound to pick elements $$$R$$$. Iterate $$$L$$$ from $$$0$$$ to $$$m-1$$$. If $$$cnt[L] \geq 1$$$, then the element already contributes to the mex. Otherwise, we need to find a location $$$R$$$ to take the next element from. Increment $$$R$$$ until:

  1. $$$R \geq 2L + 1$$$ (mod condition)
  2. If $$$R \leq m-1$$$, we need at least one element in the current location: $$$cnt[R] \gt 1$$$.
  3. If $$$R \gt m$$$, we can use any nonzero element.

Such a two pointer approach works in $$$O(n\text{ log }n)$$$.

Submission: 372875264

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

A's statement was weird, like B is 10 times clearer, and the difference between C and D in difficulty is massive

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

I've spent 2 hours on C, but for some strange reason the output in the cf tester differed with the output in my IDE. Like sometimes the tester would give me WA on the first test, although I would get the correct output in my IDE. In an online compiler I also get the correct answer. What can be the reason for that? I also asked it during the contest, but did not get an answer

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

sorry if it was newbie question, but i gotta ask.

why do we in problem one(2226A) make the answer expecting at least a single 1 in the array? isnt it possible that the array doesnt have any ones? sorry again for the newbie question, and thanks.

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

One of the best C problems in the recent contests !