TheScrasse's blog

By TheScrasse, 5 months ago, In English

text Ciao, Codeforces! We're glad to invite you to take part in Codeforces Round 1066 (Div. 1 + Div. 2), which will start on Nov/23/2025 12:35 (Moscow time). You will be given 9 problems and 3 hours to solve them in both divisions. The round will share some problems with The 2025 ICPC Southwestern Europe Regional Contest (SWERC) 2025.

Note the unusual starting time.

Some of the problems might be interactive, so please read the guide for interactive problems if you are not familiar with it.

The problems were authored and prepared by KLPP and me.

We would like to thank

The score distribution will be announced after the onsite contest starts.

We hope you'll like the problemset!

UPD 1: The score distribution is as follows:

$$$500 + 1000 + 1500 + 1500 + 2000 + 2500 + 3000 + 3750 + 4000$$$

UPD 2: Upsolving & viewing of solutions and tests will be closed until the end of the onsite contest (13:30 UTC, 1 hour after the Codeforces round ends). Please also refrain from discussing the problems in public until that time.

UPD 3: Congratulations to the winners:

UPD 4: The editorial is out.

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

»
5 months ago, hide # |
 
Vote: I like it +22 Vote: I do not like it

As a tester, I found one problem in this contest very nice, and recommend you to participate.

»
5 months ago, hide # |
 
Vote: I like it +38 Vote: I do not like it

as a commenter, I commented very fast.

»
5 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

please share the score distribution

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Wait, you mean, NINE problems within just THREE hours? This is really kind of ICPC style qwq.

  • »
    »
    5 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it +20 Vote: I do not like it

    I wanted to comment that typical ICPC contest should have 10-15 problems so actually judges had to remove something from the set (and this is usually the case). While trying to verify that, I found https://icpc.global/regionals/rules that states:

    At least six problems will be posted.

    Which means technically a Codeforces div2 round with A-F problems might be held as a regional? That's funny.

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

    it's div 1-2 for this reason

»
5 months ago, hide # |
 
Vote: I like it -31 Vote: I do not like it

Touch glass

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Will people like me lose rating from div1+div2s?

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

    Problems A-F in div1+div2 is about the same difficulty with div 2 (sometimes even easier, especially D) ,so you'll probably get a +rating if you solve A-D within 1.5h or A-E within 3h.

»
5 months ago, hide # |
 
Vote: I like it -35 Vote: I do not like it

Is it rated? IAKIOI

»
5 months ago, hide # |
 
Vote: I like it -6 Vote: I do not like it

As not a tester, I think the problems in this contest are very nice, and recommend you to participate. :)

»
5 months ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

I'm pretty sure that the onsite contest already started, where's the score distribution

»
5 months ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

As a tester, I want to know why you're not playing Honkai: Star Rail.

»
5 months ago, hide # |
 
Vote: I like it +23 Vote: I do not like it

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Will the problems still be in rough difficulty order or random like ICPC?

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

As a tester , I feel that the contest is great and I recommend to participate

»
5 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

What sort of difficulty should I expect?

I've just started on this website (yesterday) and have enjoyed my time so far.

Just wondering how hard this is going to be on a difficulty scale.

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What is the difficulty of this problem? This is my first time getting an email and I don't know if it is very hard or very easy.

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

If i don't get Cyan today, strap me up.

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

As a participant, I did not read that this contest starts a little early. As a result, I will now be doing this on mobile in chemistry class.

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

    As your chemistry teacher, I will provide you with a computer.

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

First time learning about interactive problems! I know div 1 and div 2 is out of my reach for a newbie, but I shall try my best!!

»
5 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Lucky enough to look at the unusual timing just 1.5 hrs before the contest

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

btw can I see the live scoreboard for SWERC somewhere?

»
5 months ago, hide # |
 
Vote: I like it -9 Vote: I do not like it

Where is the hacking-disabled zone for this round?

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

The contest starts in 4 minutes. GLHF guys!

»
5 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

As a human, I am a human

»
5 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

cool B

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

    I got stuck on it sadly, only started with an hour left in the comp but I breezed A but B felt like going round in circles.

»
5 months ago, hide # |
 
Vote: I like it -17 Vote: I do not like it

why is my solution being skipped while the contest is still live

»
5 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Upsolving & viewing of solutions and tests will be closed until the end of the onsite contest (13:30 UTC, 1 hour after the Codeforces round ends).

Please also refrain from discussing the problems in public until that time.

»
5 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Uh missed the contest..should have looked at the unusual time :(

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Is there a rating-predictor in Codeforces?

»
5 months ago, hide # |
 
Vote: I like it -6 Vote: I do not like it

big +delta for me, I like it

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

really awesome b ; i couldnt properly impelement the solution to c , for 2nd time in my life i solved c 2 min after the contest ended :(

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

C is rubbish

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Fun fact: I also independently submitted a problem that was almost the exact same to D to propose for a Codeforces contest. It was turned down :p

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The contest was really amazing. Thanks for arranging such a nice contest.

»
5 months ago, hide # |
 
Vote: I like it +25 Vote: I do not like it

Fun problemset!

Upsolving & viewing of solutions and tests will be closed until the end of the onsite contest (13:30 UTC, 1 hour after the Codeforces round ends). Please also refrain from discussing the problems in public until that time.

This is a bit awkward to ask everyone to do (specially since it's an announcement not many people will read). Wouldn't it be better if the round happened 1 hour later then? Were setters just not available at that time?

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My first time in a div1&2 contest

»
5 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

E<D

»
5 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

How to solve E?

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

    It's not that hard to see that this problem is easier to do with a frequency map.

    From observations you can get that when, for some $$$i$$$, $$$f_i \gt k$$$, then you have to move $$$f_i-1$$$ drones from energy $$$i$$$ to $$$i+1$$$, so basically $$$f_{i+1}:=f_i-1,f_i:=1^{(1)}$$$ ($$$:=$$$ means assignment).

    Let's define a chain reaction when $$$f_i \gt k$$$, and we advance the drones of $$$f_i$$$ to the right (thus incrementing $$$i$$$) until $$$f_i≤k$$$, leaving a trail of $$$1$$$s behind. At the end, if we started from $$$s$$$ and ended at $$$i$$$, the total number of operations that chain reaction did was $$$i-s$$$. Let's save all trails of ones in an array $$$jump$$$, in the format $$$jump_s=j$$$.

    Any chain reaction passing on an existing trail of $$$1$$$s (which starts on position $$$j$$$) will, after $$$jump_j-j$$$ operations, continue from $$$jump_j$$$ without changing the trail (ofc it will leave it's own trail of $$$1$$$s, but $$$1=1$$$, so the elements of $$$f_{j:jump_j}$$$ won't change).

    So, our answer to the problem will be the longest chain reaction. Of course, every chain reaction has a constant rate, so no chain reaction can "catch up" to another ongoing, which means it's safe to simulate chain reactions from the right, to the left.

    This means we can have a variable $$$s\in{2n,\dots,1}$$$, and we can check if $$$f_s \gt k$$$. If this is true, we start simulating the chain reaction from $$$f_s$$$, with $$$(1)$$$. If we get to $$$i$$$ where $$$jump_i$$$ is set, we can skip a lot of indexes, which saves runtime and reduces energy consumption, thus slowing down global warming. At the end of the chain reaction, if the length of this chain reaction is the largest ever, we save it ($$$m:=max{m,i-s}$$$).

    Implementation: codeforces.com/contest/2157/submission/350326830

»
5 months ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

Appreciate the starting time.UTC+8 is a timezone that is very difficult to participate in usual contests for high school students.Will CF hold more contests at different starting times?

»
5 months ago, hide # |
 
Vote: I like it +58 Vote: I do not like it

about F and G: sorry I'm not your GF.

»
5 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

the type of fumble I do when I'm 9 away from expert. Did well in my ICPC region too :(

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

ak+q is great!

»
5 months ago, hide # |
 
Vote: I like it +73 Vote: I do not like it

For Problem G, it seems easier to guess the solution than to prove it. The real challenge is mustering the courage to implement an idea you’re uncertain about.

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Where can I see onsite standings?

»
5 months ago, hide # |
 
Vote: I like it +74 Vote: I do not like it

F. G and H are both non-traditional questions that catch people off guard, and there are some random distinguishing elements for participants with scores less than or equal to 3000.

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

wtf H brute searching is correct

so shocked, so what's the intended solution

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

    The intended solution uses that $$$p_n$$$ must be large if $$$n-m$$$ is small. You seem to use that accidentally in your brute force.

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

can someone suggest me the fix for C on top of my solution, thanks!!! https://mirror.codeforces.com/contest/2157/submission/350367577

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

Will this round be another case for this?

Edit: Seems that it has been fixed now.

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

C+D > F

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

When will the editorial be released? I look forward to reading it.

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

Is there anybody who used ternary search for problem D?

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can anyone help me with a testcase why am i wa on test 5? https://mirror.codeforces.com/contest/2157/submission/350344325

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

    Probably you have to sort the mex intervals by their left boundaries? I see your code is similar to mine, and I mistakenly assumed that the intervals are in order so filling the mex intervals might be problematic (e.g., three mex intervals overlap with each other, and we filled the first and the last before filling the one in the middle). Didn't really look into the details tho, just a guess.

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

      i have filled the values greedily, Lets say — k=3, and interval is (3, 5) and (1, 4). So first i will add the values in (3, 5). Next when filling values for (1,4) i will check which all values are already there in this interval. In this case index 3 and 4 are already filled with 0 and 1 respectively. So I just need to add 2 in index 1 for completing interval 2.

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

        Let's say that the mex intervals are (1, 2), (2, 3), (4, 5) and (3, 4), and k=2. Then, if we fill the first 3 intervals greedily, we get [0, 1, 0, 0, 1], and we can find that when we fill (3, 4), we have no spare room to fill. So if the mex intervals are not in order there are some issues.

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

when will editorial be available

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

During contest, For problem E, I went in wrong direction. It is very easy with monotonic stack. Probably easier than problem C or D.

https://mirror.codeforces.com/contest/2157/submission/350385547

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Does anyone have spare time to explain F to me? I thought of sqrt decomp ($$$250000=500^2$$$) or cbrt decomp ($$$250047=63^3$$$). Unfortunately, the closest I got is 15 million robocoins, with the cube root. I don't ask for mathematical proof (99% I can prove it myself), but the idea.

Asking because I underperform in reading other people's code (aka suck at it)

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

    My solution uses $$$~9.5e5$$$ operations.

    Split number segment $$$[1, 250000]$$$ into blocks of size $$$100$$$.

    $$$[1, 100], [101, 200], [201, 300], \dots$$$.

    Let's do following operations: $$$\dots, (201, 1), (101, 1), (1, 1), \dots, (202, 1), (102, 1), (2, 1), \dots, (203, 1), (103, 1), (3, 1), \dots$$$. This way level will become divisible by $$$100$$$. We will spend $$$250000 + 1000 * 100 = 3.5e5$$$ operations.

    Now split remaining numbers into blocks of size $$$100$$$ again.

    $$$\{100, 200, \dots, 10000\}, \{10100, \dots, 20000\}, \{20100, \dots, 30000\}, \dots$$$.

    Let's do the same thing: $$$ \dots, (20100, 100), (10100, 100), (100, 100), \dots $$$. This way level will become divisible by $$$10000$$$. We will spend $$$3.5e5$$$ operations again.

    We have $$$25$$$ numbers remaining. Let's solve them trivially from smallest: $$$(10000, 10000), (20000, 10000), (30000, 10000), \dots$$$. We will spend $$$250000 + 1000 * 25 = 2.75e5$$$ operations.

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

      isnt that 9.75e5 (roughly)
      but if u actually count it should be lower by a bit (iirc)

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

      Why is splitting by dividing by 100 the best solution

      Like shouldn't dividing by 2 the best solution

      I thought about converting all number Divisible by 2 Than divisible by 4 And so on till 1024

      After that from lowest to biggest (1024,1024) , (2048. 1024), each will cost 1024 + 1000

      But was able to get a solution of 2e6 coins

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

    I use the cube root too.

    Split $$$[1,250000]$$$ into blocks size of $$$64$$$ is enough.

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

      Looking at your code. How did I not think of this… I was so close.

      I also had the idea to put everything at multiples of $$$63$$$ (you did on $$$64$$$, but close enough), but the way I did it wasn't cost-efficient. I did $$$(i,64\left\lceil\frac i{64}\right\rceil-i),i\in250000,\dots,1$$$

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Could anyone share me some problems that similar to D? I was stuck at D for nearly 2 hours because lack of greedy proof

»
5 months ago, hide # |
 
Vote: I like it +26 Vote: I do not like it

Why in D, statement is written very very confusing??? "After you decide how to deal with all the offers, the actual Billion Players Game is played." After that i started solving the problem thinking first you decide, then value in [L, R] is given. BUT it was oppsosite and very easy ):

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

https://mirror.codeforces.com/contest/2157/submission/350358558

Can anyone help me in proving the correctness of this for today's D? I reached the solution through an observation by plotting on Desmos but can't prove why it works.

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

more people , more use of AI .. less people , less use of AI

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

hi it was nice contest

»
5 months ago, hide # |
 
Vote: I like it -19 Vote: I do not like it

Hello, I received a similarity warning for my solution in this round. I did not share my code with anyone or copy from anyone. It is possible that I once used an online IDE that unintentionally made my code public. I understand this is against the rules even if unintentional, and I sincerely apologize. I will make sure this never happens again. Thank you for checking.

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

@MikeMirzayanov @Codeforces_Team Urgent: My account [AlgoMaster1] cannot view any solutions. Other accounts work fine. Cannot write blog post (no rated contests). Please check account restrictions. Thank you.

»
5 months ago, hide # |
 
Vote: I like it -7 Vote: I do not like it

Regarding solution 350335303, I did not intentionally share my code. I will be more careful in future contests. I truly respect the terms and conditions of codeforces. Thank you.

»
5 months ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

Does anyone have the same problem like me? I can see all submissions before Codeforces Global Round 30, but in a few recent rounds, I am not allowed to view any submissions. Even I can't view my own submissions. Is this a bug or a feature?