Artyom123's blog

By Artyom123, history, 2 years ago, In English

Hello, Codeforces! We're glad to invite you to take part in Codeforces Round 924 (Div. 2), which will start on Feb/11/2024 12:35 (Moscow time). You will be given 6 problems and 2 hours to solve them.

This round will be rated for participants whose rating is below 2100. Participants with higher rating can participate unofficially.

The problems were authored and prepared by vaaven, silvvasil, Alexdat2000, teraqqq and me.

The round is based on Moscow Olympiad for school students.

We would like to thank

Score distribution: $$$500 - 1000 - 1500 - 1750 - 2250 - 2750$$$

UPD: Editorial

UPD2: Congratulations to the winners!

Div. 2

  1. hmmmmm

  2. satellite.

  3. RomkaRS

  4. Alx

  5. hirayuu_cf

Div. 1

  1. SSRS_

  2. maspy

  3. kotatsugame

  4. 74TrAkToR

  5. SSerxhs

  • Vote: I like it
  • +504
  • Vote: I do not like it

| Write comment?
»
2 years ago, hide # |
 
Vote: I like it -6 Vote: I do not like it

Good luck to everyone. I hope to reach expert in this contest.

»
2 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

contemplating taking this contest at 1:35 AM :)

»
2 years ago, hide # |
 
Vote: I like it +21 Vote: I do not like it

The start time is good for Chinese.

Today is Spring festival eve.Happy new year!

»
2 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

GOOD LUCK!!!

»
2 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

bed time for pacific programmers

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hope to maintain my specialist rating.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hope that Delayforces won't come again

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Good!

»
2 years ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

need to run out of college class to attend the contest

»
2 years ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

Good luck! May the force be with us!

»
2 years ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

As a tester for this round, this round is great, please participate!

»
2 years ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

Good start time.

I can participate in contest instead of going to school :)

»
2 years ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

as a tester, i can confirm that the problems are problems

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hope to become master after this.

»
2 years ago, hide # |
 
Vote: I like it +75 Vote: I do not like it

As a taster, the contest was delicious and I ate the problems

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Nah I'd Win (I will most definitely lose)

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

bad start time, I've school ig I'm gonna be "sick"

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

lets see if i can become specialist

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Bad time contest for New York contestant

»
2 years ago, hide # |
 
Vote: I like it -74 Vote: I do not like it

The round is based on an official russian competition. I don't know why the authors decided to support the existing system by organizing official events, but I encourage other users to avoid this mistake. Many other competitions are more worthy of your problem ideas and participation.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    bro look at your profile picture, i can find it googling "cute авы стим аниме", you can't be taken seriously XDD just go chill somewhere, no need to litter here

»
2 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

Hope to get a negative deltaa so that div 3 becomes rated for me.

»
2 years ago, hide # |
 
Vote: I like it +27 Vote: I do not like it

Rankup time...

6 contests in a row!

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Good luck!!!

»
2 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

GOOD LUCK!

»
2 years ago, hide # |
 
Vote: I like it +18 Vote: I do not like it

Today is a special day for the Chinese (the second day of the Chinese New Year) and it's also a good start time for the Chinese.I think it may be a wonderful contest.

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Let's skip class and reach specialist.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Will Reach CM after this round

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Guess the rating of Problem

»
2 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Good time, hope i solve A fast

»
2 years ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

Fantastic

Because my mind is more active at 17:35 (UTC+8)

I'm Chinese

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Good luck!

»
2 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Happy Chinese new year!Good luck to everyone.

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Any ways the start time is good for India. Sunday afternoon :)

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I wish I will have positive delta during Chinese New Year!

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I hope be expert in this contest!

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

First CF Contest

»
2 years ago, hide # |
 
Vote: I like it +4 Vote: I do not like it
Me after the contest :
»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hoping to reach expert with this round

»
2 years ago, hide # |
 
Vote: I like it +59 Vote: I do not like it

Judgement failed?

»
2 years ago, hide # |
 
Vote: I like it +22 Vote: I do not like it

glad to see another Mathforces round.

»
2 years ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

nice math contest

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I am considering whether to die or not,because I only complete question A.

»
2 years ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

MATHFORCES :((

»
2 years ago, hide # |
 
Vote: I like it +23 Vote: I do not like it

Did they assume us mathematicians?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

is $$$D$$$ binary search?

  • »
    »
    2 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    Yes. Observe that as you increase the number of squads, the amount lost by b only increases by a fixed amount(b), while the amount gained from adding a new squad, decreases as you add more. Therefore, we should find the amount of squads at which adding a new squad gives less than b. Since the amount given by a new squad decreases monotonically, we can use binary search.

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      yeah bro I mind solved it but didn't have time to implement , wasted a lot of time in $$$C$$$

    • »
      »
      »
      2 years ago, hide # ^ |
      Rev. 4  
      Vote: I like it 0 Vote: I do not like it

      Though binary search may work, it isn't actually needed to solve it.

      You can just realize that the number of pairs for a group with $$$c_i$$$ members only increases till the number of groups becomes $$$c_i$$$, so you can just recalculate it for each $$$1 \leq \text{squad size} \leq c_i$$$. This runs in $$$O(n + \sum {c_i})$$$ which is fast enough for the constraints.

      Code — 245818007

      • »
        »
        »
        »
        2 years ago, hide # ^ |
         
        Vote: I like it -8 Vote: I do not like it

        ExplodingFreeze why your solution passes time complexity,

        N : 10^5

        max(c): 10^5

        O(N*max(C)) = TLE right? please explain if i missed something

        • »
          »
          »
          »
          »
          2 years ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          You actually don't have to recalculate every time (I see that he used the pop_back function for the optimisation), so the solution is only O(N+C)

        • »
          »
          »
          »
          »
          2 years ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          See the last line of the input section — "It is guaranteed that the sum of the values $$$c_1 + c_2 + \cdots + c_n$$$ over all test cases does not exceed $$$2\cdot10^5$$$."

          So $$$O(n + \sum{c})$$$ is by definition fast enough.

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it +9 Vote: I do not like it

      This is a convex function, which can more easily be solved with ternary search.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +5 Vote: I do not like it

    kind of, I get AC with a ternary search for the amount of groups we are doing, run time is O(n * log (max C))

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hint for C please

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it
    hint
    • »
      »
      »
      2 years ago, hide # ^ |
      Rev. 2  
      Vote: I like it 0 Vote: I do not like it

      Yeah, I considered those cases, but still unable to come up with solution. What I came up with after doing some calculations is to find number of even factors of (x-n) and (x+n-2) such that size of one unit of repetition is atleast n. Is this approach correct?

»
2 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Good contest, interesting problems. Thanks to the authors.

»
2 years ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

how to C

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve D?

  • »
    »
    2 years ago, hide # ^ |
    Rev. 3  
    Vote: I like it +3 Vote: I do not like it

    notice that sum of c[i] <= 200000 => number of different c[i] is at most sqrt(200000) => simply iterate over all possible num of squads in O(max(c[i]) * sqrt(200000))

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +11 Vote: I do not like it

    Suppose a group with $$$c_i$$$ members is divided into $$$k$$$ pairs, then it is optimal to split it into groups of size $$$\lfloor \frac{c_i}{k} \rfloor$$$ and $$$\lceil \frac{c_i}{k} \rceil$$$ to maximize the number of pairs. You can trivially calculate the number of groups of each size and the number of pairs for a given $$$c_i $$$ and $$$k$$$.

    Then just realize that the number of pairs for a group with $$$c_i$$$ members only increases till the number of groups becomes $$$c_i$$$. So if you iterate on squad size in increasing order, you can just recalculate it for each $$$1 \leq \text{squad size} \leq c_i$$$ and then maintain the last value in a common sum. This runs in $$$O(n + \sum {c_i})$$$ which is fast enough for the constraints.

    Code — 245818007

»
2 years ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

bad F.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Problem D: binary search on answer(no. of squads) because the target function has only one extreme large value

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

first time ever that I couldn't solve A, I still have no idea

extremely frustrating actually

»
2 years ago, hide # |
 
Vote: I like it +26 Vote: I do not like it

Very dramatic that hmmmmm solved problem F in the last minute(may win a prize in some contests) and became the only AK. Congratulations!

»
2 years ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Really tough B

»
2 years ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

I found D easier than C.

»
2 years ago, hide # |
 
Vote: I like it +74 Vote: I do not like it

If the round is based on some olympiad, I guess it's understandable that the authors didn't have the time to fine-tune the TLs for codeforces, but still repeatedly getting TLs in F with $$$\mathcal{O}(n\log n)$$$ was pretty frustrating

»
2 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

Anyone else spend a long time without realizing that the triangle numbers start from "0" in E? I spent like 1 hour trying to think about how to calculate both exact length and sum before realizing right at the end that only min length was required T_T.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I want hint for B

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I got WA2 on problem E. What is incorrect in this solution?

$$$x \; mod \; y$$$ subtracts $$$y$$$ from $$$x$$$, so it makes sence to work with multiples of $$$y$$$. Look at this sequence: $$$a_1 \cdot y + p, a_2 \cdot y + p, \dots$$$, where $$$p = x \; mod \; y$$$. Then either $$$a_i = 0$$$ or $$$a_i = a_{i-1} + 1$$$, so this is a sequence of arithmetic progressions.

What is the sum of sequence? It is $$$\sum_i{(a_i \cdot y + p)} = y \cdot \sum_i{a_i} + n \cdot p = s$$$. This gives $$$sum = \frac{s - n \cdot p}{y}$$$. Check that this is an integer number.

Now our problem is to find sequence of arithmetic progression with given length $$$n$$$ and sum $$$sum$$$. We can find minimal length instead, and after it append zeros at the end. Let's first $$$a_1 = 0$$$. This is a simple $$$dp$$$. We iterate over length of additional progression. There are $$$\sqrt{n}$$$ of them, so it takes $$$O(n \cdot \sqrt{n})$$$ time.

How about $$$a_1 = \frac{x}{y}$$$? Let's just iterate over all prefixes-progressions and find the best one prefix.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

B problem implementation triki but logic easy.

»
2 years ago, hide # |
Rev. 2  
Vote: I like it +29 Vote: I do not like it

Why anyone would just cheat to get better rank? For real I don't know how you doin that and u think u are good but the fact that u r cheating

Problem C is not that easy to get 3k accept

Fu*k youtube channels and telegram and anyone that take anything from them

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve the problem c? I got TLE with this solution: https://mirror.codeforces.com/contest/1928/submission/245842512 anyone please explain.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Notice that the position where x appear is x and 2k — x adding 2k — 2

    so what you need to do is calc the number of k satisfy n % (2k — 2) = x or n % (2k — 2) = 2k — x

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      I understood the part where we need to find all divisors for n — x, but why do we need to check the n + x — 2. Can you help me please?

      • »
        »
        »
        »
        2 years ago, hide # ^ |
         
        Vote: I like it +3 Vote: I do not like it

        Case $$$1$$$: $$$n\mod (2k — 2) = x$$$.

        This means there exists some $$$y$$$ such that, $$$(2k - 2) * y + x = n$$$ $$$\rightarrow$$$ $$$(2k - 2)*y = (n - x)$$$. So, if we find divisors of $$$(n - x)$$$, we can find the candidate values for $$$k$$$.

        Case $$$2$$$: $$$n\mod (2k - 2) = (2k - x)$$$.

        This means there exists some $$$y$$$ such that, $$$(2k - 2) * y + (2k - x) = n$$$. Subtract $$$2$$$ from both sides, $$$(2k - 2) * y + (2k - 2) = n + x - 2 \ $$$ $$$\rightarrow$$$ $$$(2k - 2)(y + 1) = n + x - 2$$$. So, if we find divisors of $$$(n + x - 2)$$$, we can find the candidate values for $$$k$$$.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I have applied Binary search on 1928D - Lonely Mountain Dungeons and got Accepted, but I think my solution can be hacked. Try it.

»
2 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Bad start time , i need to eat dinner with my family during the spring festival.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Well balanced round although a bit mathy.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

GOOD ROUND !!

On my way to Specialist

»
2 years ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

I wonder if this is an intended solution for E, or is this hackable.

https://mirror.codeforces.com/contest/1928/submission/245851958 (hacked)

https://mirror.codeforces.com/contest/1928/submission/245926933

The problem can be reduced to constructing an array of length n of sum z where

  • the starting element is fixed
  • each other element is either zero, or one larger than the previous element

The strategy is to greedily increase, except for the following scenarios

  • The remaining budget (the target sum z minus current array sum) is a triangular number and the remaining space (target array length n minus the current array length) is at least one more than the size of the triangle.
  • The remaining budget (the target sum z minus current array sum) is a triangular number plus one and the remaining space (target array length n minus the current array length) is at least three more than the size of the triangle.
  • The remaining budget (the target sum z minus current array sum) is a triangular number plus three and the remaining space (target array length n minus the current array length) is at least four more than the size of the triangle.

In other words, the only times you do not go greedy is when the constructed array ends in

[..,0,1,2,3,4...,n,(and maybe a few more zeroes)]

or

[..,0,1,2,3,4...,n,0,1,(and maybe a few more zeroes)]

or

[..,0,1,2,3,4...,n,0,1,2,(and maybe a few more zeroes)]

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Very tricky E!

»
2 years ago, hide # |
 
Vote: I like it +19 Vote: I do not like it

Welcome to Mathforces dot com

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can someone explain in for testcase 3 in D why the answer

1 1 5 5 16

is 525? I calculate 530 when I use 10 squads. I even did a brute force of the squads and get the following

1 0 2 315 3 415 4 465 5 490 6 505 7 515 8 525 9 525 10 530 11 530 12 530 13 530 14 525 15 525 16 525

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can anyone tell me if the penalty applies only for solved problems? If I have submited 3 wrong answers for a problem but I fail to ultimately solve the problem, will my overall points still be reduced by 150? Thank you.

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

If the contest starts at an unusual time, at least mention it in bold. I overlooked the start time and missed the contest :(

»
2 years ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

very classic problems. dislike

»
2 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Bad start time, I need to have dinner.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

D could be solved with brute-force, by fixing the number of squads, and iterating over the races with population higher than the fixed value.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +8 Vote: I do not like it

    It is $$$O(s \sqrt{s})$$$ actually, or something like that

    • »
      »
      »
      2 years ago, hide # ^ |
      Rev. 5  
      Vote: I like it 0 Vote: I do not like it

      Actually, I think it works in $$$O(N \log N)$$$ where $$$N = 2.10^5$$$ as $$$\sum_{k=1}^{N} \frac{N}{k}$$$ is $$$O(N \log N)$$$, and the sum of values of $$$c_i$$$ is bounded by $$$N$$$ in all test cases. I don't have exact proof but it passed in 31 ms, and I don't think $$$O(N \sqrt{N})$$$ is that fast.

      • »
        »
        »
        »
        2 years ago, hide # ^ |
         
        Vote: I like it +2 Vote: I do not like it

        I guess it is just because of the weak tests. It is exact $$$\mathcal{O}(n\sqrt{\sum c_i})$$$.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can anyone tell why my code for problem B fails so hard on test case 3?

  • »
    »
    2 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    One quick observation: when you update your answer, you should use max instead. This way, you get the best answer (largest possible interval) and not the most recent one.

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Well I get the largest possible interval anyways because r-l only gets smaller in the code I wrote. The only possibility is that my approach does not yield the optimal answer, and I'd like to know why that is.

      • »
        »
        »
        »
        2 years ago, hide # ^ |
        Rev. 2  
        Vote: I like it 0 Vote: I do not like it

        Makes sense. Indeed, your algo doesn't get the optimal answer sometimes. A good strategy to prove this is to find a good counterexample.

        What you are doing is you make the interval to consider smaller based on which difference in values of either the right or left end is bigger. Let's try to find a correct answer that exploits this.

        Try for example: [1 2 3 501 502]

        The optimal subarray is [1 2 3]. Notice that your algo disregards 1 at the first iteration, so that's a valid counterexample.

        A hint to solve the problem: assume that we have a set of (distinct) values and we want to make them equal using a permutation. Try to find what condition we need to have in order to make all the values of this subset equal.

        Let me know if you need more help! :)

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I had good contest but the ratings was too bad and I got positive rate only for 14

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

can someone hack this solution? -> https://mirror.codeforces.com/contest/1928/submission/245838079 this solution uses unordered map and i think it can be hacked?

»
2 years ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

Square_root_forces

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

i wish there was at least a reminder that we could put even so the start time is bad anyways so

»
2 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

I don't really believe this solution for problem E is correct, but for some reason it passed all the tests:

  • Brute force the largest index i before we take element modulo y.

  • For the rest of the array (after index i) try to distribute sum across the elements greedily (it gets WA11 without the next step).

  • Before doing the greedy thingie, try to remove prefix of length L (L is from 0 to 10) and pick the way with the least number of elements required.

Am I right that this solution doesn't look correct?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Bad time.missed the round due to different timing.

CF needs to bring some UI changes on contests page.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

One of the most interesting contest I've ever written, Thanks)

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Thanks to the round, finally an Expert

»
2 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

A really good contest, even though the contest inspired by olympiads are generally more mathematical than usual but this one had a great balance. Great work by authors!!

»
2 years ago, hide # |
Rev. 2  
Vote: I like it +1 Vote: I do not like it

.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Honestly I don't think this contest should be regarded as mathematical, as least the first five problems (which I solved during contest). I'm only a junior 2 student that had only learnt junior high school math and a little of senior high school math, and I have no MO background. I believe lots of people have an age larger than mine, so imo they have math knowledge better than me, st they shouldn't think this is a "math" round.

I've faced many times that people say that "... round is full of math", but I usually cannot understand (once was a round I VPed when I'm in primary school)