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

Автор Serval, 13 месяцев назад, По-английски

Hi Codeforces!

I Serval am glad to invite everyone to participate in Codeforces Round 1011 (Div. 2), which will be held on Mar/22/2025 17:35 (Moscow time).

This round will be rated for participants with rating lower than 2100. We will be glad to see the participants with a higher rating to take part in our round unofficially as well!

You will be given 6 problems to solve in 2 hours, one of which will be divided into two subtasks. Scoring distribution will be announced later.

I would like to thank everyone that makes this round possible:

Good luck & Have fun! (∠・ω < )⌒☆

UPD: Scoring distribution: 500 — 1250 — 1250 — 1750 — 2500 — (2000 + 1000).

UPD2: Editorial is out. Congratulations to the winners!

Div. 2:

  1. sounansya
    DuyNgaDocTon1410 Disqualified.
  2. SoloRE
  3. nocap
  4. Asbjorn
  5. AksLolCoding

Div. 1 + Div. 2:

  1. potato167
  2. A_G
  3. arvindf232
  4. antontrygubO_o
  5. TKT_YI
  • Проголосовать: нравится
  • +383
  • Проголосовать: не нравится

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

As a coordinator, I was playing Genshin with the author!

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

As a tester, I think Serval is a cool character in Star Rail

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

Here comes :

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

[deleted]

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

As a participant, I recommend all of you to watch Kemono Friends. (BUT NO ONE SHALL WATCH SEASON 2!!!)

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

;gimme 1603

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

How to be a tester ?

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

I wish we could have a

^-^

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

add this blog to the home page?

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

As a tester, I'm too late...

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

As a tester serval is a super cool character who displays indirect buffing so well. After the introduction of the herta serval skyrocketed into a meta sub dps due to driving her super so well when using s5 passkey. But she'll probs fall off again like every good 4 star like gallagher or Moze

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

WOW~~~~~~~~~

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

as somebody who was supposed to test, my pc still isnt fixed and im writing this from my phone :(

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

As an 8-year-old girl, Hope to solve two problems in my first codeforces round.

UPD: I do it!

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится
Some lyrics you might want to enjoy with this round
»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

First contest I take this month, hopefully reach master

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

I hope the problems are not a pile of crap.

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

aiming for the blue color...

hope that it will be a good round for everyone... && hope that cheaters will not participate in this contest..

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

Why is this round special?

Spoiler

sorry sorry! I forgot..! tnx!

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

I wish this round is good and we all can reach high rating.

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

Good luck & Have fun! (∠・ω < )⌒☆

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

As a tester, I enjoyed the problems more than the bananas

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

There will, and there shall be a Serval round!

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

Good luck have fun everyone.

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

I hope it goes well.

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

^-^

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

I'm like very new, so how does a contest work?

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

    Note that the contests vary in difficulty. It can be Div.1, Div.1+2, Div.2, Div.3, Div.4, where Div.1 is the most difficult and Div.4 is the easiest. Normally Div.3 and Div.4 are for school pupils, Div.2 for university students and Div.1 for pros. Actually, you can participate in any.

    Practice with the problems from previous contests, register for the contest, prepare mentally for a sprint, start in time and do your best!

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

As a tester, I think the problems are very Serval.

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

Is there some specific reason the email announcement for this contest did not mention Rust in the list of accepted languages?

Допустимые языки C/C++, Pascal, Perl, Java, C#, Python (2 и 3), Ruby, PHP, Haskell, Scala, OCaml, Go, D, JavaScript и Kotlin.

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

GLHF everyone except cheaters!

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

Here's an image of the standings after 1 hour. Anyone can see a pattern here

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

Solved C in 5 minutes and then staring at D, i hate these speedforces.

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

after long time I made all questions (A -D) with logic and not much guesswork .. finger crossed for system test

unfortunately I made wrong submission for div2B .. indices should be with respect new array LOL...

hello "expert" my old friend / rank

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

how to solve C ?_?

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

what is the general idea for solving c

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

C was too difficult for me..

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

speedrun through ABC but stair at D and F1 till the end of contest.

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

lol, the terrible C did not allow to solve the interesting E and F1. Why do we have to play guessing games all the time?

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

how to F1

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

I really hate problem of kind C if you know the 'gimmick' a + b = (a & b) << 1 + a ^ b then it's free otherwise you are screwed

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

Please explain C in simple and step by step how to solve. Thanks in advance for your help....

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

I stuck at D by thinking about dp, nooo

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

Fun Contest! Thank you for the problems.

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

How to solve D ? Can we use dp ?

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

    We can use priority queue.

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

    Let's go backwards. If at some suffix you know what's the best you can do, then when you add another plate at the start, there are some choices:

    • Take it, if there's enough time to finish it in the future

    • If it can't be just taken, and before you took a plate with lower value, then you can switch them and improve the answer

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

      I did the same, I was very happy that I didn't miss any corner cases as well.

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

      I may be stupid but I don't understand why d[i] + extendable_suboptimal_solution_for_suffix can't be better than d[i] + best_solution_for_suffix — smallest_val_in_best_solution in case when we can't extend the best solution for suffix

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

        By definition, every extendable suboptimal solution can be extended to make it not extendable, and let’s say, it is extended in the best way. From that non-extendable solution, the best we can do is switch the current value by the smallest in the solution. And as the current solution is the best of that kind, then it is optimal to stay with it and make the possible changes

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

          I was confused about the case when it's extentable with the current element and isn't with any element to the right, but I think I got it now.

          It probably should be intuitive, it's totally not for me, but I did some math and found out that in this case the extended suffix will contain the maximum possible number of plates. And I spent some time understanding that the best solution for suffix should also contain this number of plates because it can't be extended(again, it wasn't intuitive for me that a good solution can always be extended if the number of plates in resulting solution won't be greater than the maximum for the extended suffix(I thought it may become bad after extending), so if a good solution can't be extended it should contain this maximum number of plates to "overflow" after extending, it's the only way it can become bad). And as the number of plates is equal the modified best solution is obviously better.

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

D was a cute problem.

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

Can anyone hack my submission for E?
It's basically just bruteforcing over all possible k(found from using the max of a and the differences with the elements of b), but pruning the amount of k with some optimizations.
I got a sum total of 8 WA by being stupid and not realizing I wrote it wrong :(

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

Interesting problems, really brainstorm. I like it and it let me become CM:))

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

Can anyone share solution to F2?

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

How does E work?

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

    yeah me too waiting for editorial for this.

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

      If $$$b$$$ is a permutation of $$$a$$$, then any number larger than $$$max(a)$$$ is OK.

      If $$$sum(b) \gt sum(a)$$$, the answer is $$$-1$$$.

      Otherwise, calculate $$$d = sum(b) - sum(a)$$$, $$$k$$$ must be a factor of $$$d$$$.

      Enumerate each factor of $$$d$$$ and test if it satisfies, with 2 optimizations:

      (1) $$$k$$$ is larger than $$$max(b)$$$; (2) If $$$k_0$$$ is not the answer, the multiples of $$$k_0$$$ is not, either.

      If no such $$$k$$$ exists, the answer is $$$-1$$$.

      my solution

      UPD: My solution was too complicated when calculating the factors of $$$d$$$. x_x

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

    Let's assume that array b is arranged correctly. This means that a[i]=k*q+b[i], where q is some non-negative number; This means that sum of a is equal to k*m + sum of b. So if we substract sum of a from sum b, we get some number that is divisible by k. So K is one of the divisors of (sum a — sum b)

    You can just iterate over each of the divisors of (sum a — sum b) and check if any of divisors can get you an array which is equal to b.

    Note that you can reduce the number of divisors that you have to iterate through, because k is greater than maximum of b (a % k < k) and a%k=a, if k > a, so k is less than maximum of a, if array a is not equal to b, or k is just any number bigger than maximum of a, if a is equal to b.

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

Fun fact: I Wrong answer on pretest 2 on B for 4 times, and the time I used to solve B is equal to the time I used to solve D + the time I used to solve E.

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

A nice contest!

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

very fun and interesting round i loved b and c in particular, codeforces just doesn't get better than this

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

311834563

First time I'm commenting something, so my bad in case of any mistake.

I don't know why my code is giving WA on problem A. I tried to think of test cases which may be the issue but I failed to come up with that. After contest to check the failed test case, it was 353rd token on pretest 2, so I couldn't read that. Just as a last resort, I tried AI to understand the flaw in my code but that didn't work either.

Thanks in advance, for any reply/help

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

Could anyone prove the time complexity of my solution for E or hack it?

Here are two versions of it: 311889161 and 311897982. The only difference of them is explained in bold.

  • Sort both $$$a$$$ and $$$b$$$.
  • Check if any $$$a[i] \gt b[i]$$$ exists. In that case, the answer is $$$-1$$$, because $$$a[i] \mod k$$$ can only be smaller than $$$a[i]$$$ but not any larger.
  • Eliminate the longest prefix of $$$a$$$ and $$$b$$$ where they're equal to each other. If this is the entire array, then $$$k=10^9$$$ is sufficient.
  • Set $$$mx$$$ as the largest element of $$$b$$$.
  • Let $$$x$$$ be the smallest element of $$$b$$$. Subtract $$$x$$$ from all elements of $$$a$$$ and $$$b$$$.
  • Now we know that there is at least one element where $$$b[i]=0$$$, so we only need to test every $$$k$$$ where $$$k$$$ is a divisor of at least one element of $$$a$$$. So, make a set of divisors of all elements of $$$a$$$.
  • Make a counting array of all elements of $$$b$$$.
  • Now for every element of the set that is greater than $$$mx$$$ (because if $$$k \lt =mx$$$, then all elements of $$$a$$$ will be less than $$$mx$$$ when $$$\mod k$$$), make another counting array that counts $$$a[i] \mod k$$$. While making this array, if any counter exceeds the same element of $$$b$$$'s counting array, break the loop. If the counting arrays match, $$$k$$$ can be the answer. If none of them satisfies it, the answer is $$$-1$$$.

Without breaking the loop, the time complexity will be $$$\mathcal{O}((\text{distinct number of divisors of a)} \times n)$$$, which should have a far greater number of inner loop iterations than just $$$n^2$$$, but 311897146 this submission shows that it didn't even run $$$5$$$ million times on any of the tests due to the break.

The version that does not break the loop still passes in $$$531$$$ ms, but it's certainly because of the tests being weak, since I was able to make a test that makes the loop run $$$\sim 322$$$ million times, although it still wasn't enough to be hacked and it passed in $$$1671$$$ ms. Could anyone hack this version, at least?

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

I found problem C a lot harder than problem D. I ended up solving it with dynamic programming to find the minimal value of $$$k$$$.

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

Is top 2 of today div 2 abusing AI to cheat in this contest?

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

Enjoyed the contest mostly because it was more on thinking about the problem rather than just being some derivation of some standard problems.

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

I'm stupid. Can anyone point out the bug? It passes the first test and fails on the 88th of the 2nd pretests.

https://mirror.codeforces.com/contest/2085/submission/311931598

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

Just curious

For Div 2B the constraints were n <= 5000

was it becuase of implementing the checker or simply to confuse Serval

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

    The checker runs in $$$O(n^2)$$$ because of the array manipulations in each operation. An $$$O(n^{1+\varepsilon})$$$ checker needs some DS to optimize it. Leave it as homework. :)

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

Top 5 lets go!