makrav's blog

By makrav, 2 months ago, translation, In English

Hello Codeforces,

I'm so excited to invite you to participate in Codeforces Round 1111 (Div. 2), which will be held on Jul/18/2026 17:35 (Moscow time)!

You will be given $$$6$$$ problems to solve, one of which will be divided into subtasks. The problems were authored by me, makrav, and PvPro.

The contest was prepared by two IOI 2026 participants from Russia, so you can be sure that the problems are of the highest possible quality.

I would like to thank these people for making the contest possible:

The score distribution is as follows: $$$500 \ — \ 750 \ — \ 1250 \ — \ (1500 \ + \ 1250) \ — \ 3000 \ — \ 3500$$$

UPD: Editorial

Congratulations to the winners:

Unofficial participants:

  1. potato167

  2. peti1234

  3. maspy

  4. golomb

  5. lnsuyn

Official participants: (subject to change)

  1. zhenja

  2. phantomas

  3. AbdullahIshfaq_

  4. n685

  5. menborong

First solves (subject to change)
A. 00:01:14 by sivi_21
B. 00:03:32 by sevlll777
C. 00:05:38 by AshikeRuet
D1. 00:03:09 by HugeWide
D2. 00:20:32 by potato167
E. 00:29:55 by soumya_ranjan17
F. 00:46:05 by SleeplessSouris

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

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

Our 15th contest

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

last binary contest :|

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

I guess it's speedforces for Problem A,B and C:)

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

As a tester, i can't read

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

aaa_Pigeon2 ..., please, don't post .

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

is next contest after this one really 2 weeks later?:( or there will be contests between this contest and the contest that is shown in contest section for 2 weeks later :)

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

    Maybe the admins will add more contests between the two.

    Even if they won't, you can still enjoy contests like ABC or ARC:)

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

Our last binary contest for us all :(

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

Last binary contest.

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

Hopefully no more NASA-level constructive algorithm and game theory.

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

as an unlisted tester i secretly tested

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

Thanks for the round , Wishing everyone the best of luck

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

Hope my rating keep 2026 after this contest :)

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

It's so legendary to witness the last binary contest in person.

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

Pov:: Rate -200

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

Amazing number!

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

We got last palindrome contest before GTA 6 :)

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

what if this contest is full of bit manipulation and palindrome based question, just saying.

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

i want to be pupil please make questions easy level

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

I will be live post contest discussion stream here

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

UPD: ok ok... my guess was wrong :(

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

B was good

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

Ideas for $$$D1$$$?

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

    Answer is always a power of two (or zero if the array is already sorted).

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

      $$$2^{mx}$$$ where $$$mx$$$ is the maximum bad index, i.e., we compare $$$a$$$ and a sorted version of it and a bad index is where $$$a_i \ne b_i$$$? This is what I tried, but it's wrong :(

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

        i think we need the maximum different power of $$$2$$$ between an index and the index the value is supposed to be at. so if a number is at index $$$j$$$ and should be at index $$$k \neq j$$$, we look at $$$2^{\lfloor log_2(j \oplus k) \rfloor}$$$ and take the max over all of these and $$$0$$$

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

      That was exactly what I found out but still gott wronng ansss

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

      why??

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

        (Using ^ to mean xor here:) Suppose we want to swap indices i and j. We can express i^j as a sum of powers of 2 corresponding with the 1-bits in the binary representation of i^j, then perform a sequence of swaps at distances that are powers of 2.

        That means if the highest one-bit in i^j is pow(2,m), we can swap i and j if and only if k ≥ pow(2, m). Values of k in between powers of 2 don't change the pairs of indices that can be swapped (indirectly): only values of k that are powers of 2 unlock new swaps.

        Concrete example: to swap 11 (0b1011) and 17 (0b10001); we can calculate 11 ^ 17 = 26, so when k ≥ 26 we can swap them directly. But we can decompose 26 = 0b11010 = 0b10000 + 0b01000 + 0b00010 = 16 + 8 + 2.

        This means that already when k ≥ 16 we can swap: 11 with 11^16 = 27, 27 with 27^8 = 19, 19 with 19^2 = 17. Now the element at index 11 is at index 17. (The element that was at 17 is now at 19; we can do the swaps in reverse to move it to element 11, and then the effect is that 11 and 17 are swapped while no other elements have moved.)

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

    I can tell it we had to go by powers of 2 I suppose, however I couldn't figure out, but point of interest was near the powers of 2. Waiting for editorial

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

      I thought the the value of k would at most be highest bit of the largest index not in its correct sorted position. I tried but it didn't work. I suppose you can reduce the value of k further if there were other guys with the same highest set bit so they cancel out..can anybody tell me was this the solution...

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

    Binary search

    When checking for k, you can notice that each block of size x (smallest power of 2 greater than k) can be swapped arbitrarily, so the smallest x numbers need to be in the first x, next x numbers in the next x positions, ect

    idk for D2 tho, someone pls help, is it segment trees?

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

    The thing is that we group elements by groups of 2^m from left to right. For example: A = 2, 1, 5, 2 -> [2]. [1]. [5]. [2] -> [2, 1], [5, 2] -> [2, 1, 5, 2] And we check whether sorting every group independently sorts the whole sequence: A = [2], [1], [5], [2] Not sorted A = [1, 2], [2, 5] Sorted so we print the size of the group.

    This solution works for every array A except for when A is already sorted, in which case we print '0'.

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

      In case of a group missing elements, for example when A = 1, 2, 1 we get [1, 2], [1, _], we fill the missing numbers with max_a[i] because it doesn't affect the result. In the case of 1, 2, 1, the groups would be [1, 2], [1, 1000000000]

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

      huh but it doesn't work for this array 2 5 3 4 1 6

      Here the answer is 4 but sorting 4 elements by group [2 5 3 4], [1, 6] doen't sort the array

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

        Sorry, I forgot to say "divided by two" so we would try with 8-sized groups and we print 4. Also, in case we try with 1-sized groups, we would print 1/2 which would be rounded to 0.

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

    k = max(k, MSB(current index after sorting ^ index before sorting))

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

I need stronger examples in C and D

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

How D2 awa

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

    First solve D1 with merge sort.

    Then, the initution of that using some data structure comes out.

    Well, let's try segment tree first(for convience, push $$$10^9$$$ to the back of $$$a$$$ until length of $$$a$$$ is a power of 2). So, our segment tree must maintain the answer itself.

    Let's say a chunk is an interval starting at $$$x \times 2^y$$$ with length of $$$2^y$$$. $$$y$$$ can be 0.

    By looking at the procedure of D1, we'll see that for a chunk, if the maximum of the left half is strictly greater than the minimum of the right half, then $$$k$$$ must be at least the length of the chunk divided by 2.

    So we just maintain range minimum, range maximum, and answer(note that we made the length of $$$a$$$ a power of 2, so a node on the segment tree just maintains a chunk).

    TC: $$$O(n + q \log n)$$$

    Implmentation

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

D1 GOOD problem.

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

I could NOT submit my solution to D2 due to cloudflare. How to solve this problem.

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

I forgot that merge sort tree works in O(log^2) and tried to use it in D2. Does anyone have ideas on D2?

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

    I thought log(n)^2 = log(n^2) = 2log(n) lmao :(

    I got a O(q*log(n)^2) solution using binary search and segment trees, but it TLEs :(

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

    Having blocks-split array, and knowing max and min in each block, array can be sorted if $$$max_i \leq min_{i+1}$$$. You can keep such "broken" pairs of blocks for each log-level if you do segment tree updates, and verify the vertex against it's left and right neighbors

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

D is a really awesome problem. I am not sure why $$$10^6$$$ is needed as constraint considering solution seems to be $$$n log n$$$, but anyway really cool one. And the update part adds some cool complexity.

It was really unexpected for me to have a need for formula of left/right neighbor in a segment tree (and generally, analyzing it's layers seems super cool!).

For E it was not obvious that (n, 1) path is also needed. The problem without closing the loop seems maybe even more interesting, so I spent quite some time on it and seems to be a bit late to solve:(.

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

    I think the $$$10^6$$$ is meant to prevent some $$$O(n log^2n)$$$ ideas for D2 like maintaining a set for each $$$2^k$$$-sized interval.However they didn't make it tight enough to prevent some $$$O(n log^2n)$$$'s from passing on D1 (like sorting on each $$$2^k$$$ interval)

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

A,B,C were fire :D

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

https://codeforces.me/blog/entry/133949

Was there really a necessary reason for D2 to have n,q <= 1000000 rather than 200000 or even 500000 on a 2 second time limit? All this really did was pretty much screw over anyone using Python. (https://codeforces.me/contest/2247/status)

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

Did anyone have a segment tree implementation for D2?

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

Problem C with subarray instead of subsequence could be interesting. Wondering if there is an efficient solution. Wasted most time trying to solve that.

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

    In problem c the only observation was you have to see how many 1's you have to invert as you can invert any number of zeros with a 1. So if number of 1s to invert are even than answer is 2 otherwise answer is 1. However you have to also check one case where number of 1s to invert are zero but there are zeros you have to invert to 1. so in this case the answer depends on whether ther is a 0 that doesn't need to be inverted in which case answer is 2 otherwise answer is -1.

    edit: yeah there is one more annoying case when there are no 1s than the answer is -1. I was dumb enough to get wa on this case and got stuck in it for nearly an hour :(

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

      That was my logic, but i missed the part where the numbers of 1s to invert are zero but there are zeros that you have to invert, and i lost a 250 points because of that :(

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

Finished this game and I had to say there are so many construction games in this contest

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

Was an honor lost rating to the last binary contest

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

Really awesome contest!!!

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

I'm so unlucky... I did not have time to participate... nooo... BTW good problems. I could be MASTER XD

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

I think i got lucky because i coded D1 like almost brute-forcably only adding pragmas it is like 60% brute

(if there is a hacking phase i wouldnt think ill be safe from TLEs)

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

D is a great problem, I got D1 but unfortunately, I couldn't solve D2 in time.

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

    hi, can you explain mei D1

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

      Let's call i is the original index of a[i] and j is the index that a[i] needs to be be placed in in order to get the array non-decreasing and i<j (if i>j we can swap i and j). If you make 1 operation, it will need x = i xor j. Note that the statement says that we must minimize the k, not the operation, so we can just xor i with every bit 1 of x in binary to get j and the maximum k needed is the highest bit 1 of the x. For duplicating a[i]s, we have an approach that the a[i] from left to right must be placed in b[i] also from left to right, with b is the array when sorted a.

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

E < C. The first guess works. 3000 points for what, yikes.

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

I had made 3 submissions for the problem D1. Initially 3 of them were accepted. But, after the contest ended, 2 submissions were marked with the verdict "Skipped" and only the last Accepted submission of D1 has the verdict "Accepted". Due to this, my score for D1 got reduced. Any idea why this happens?

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

    From the official Codeforces rules:

    If a contestant submits several times a problem's solution that passes all pretests, then the last solution is considered as the contestant's verified solution for this problem. All other solutions will be considered as unsuccessful attempts.

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

Hello, could you please explain why my account was blocked during this contest?

Account:

https://codeforces.me/profile/troyanorte

https://codeforces.me/submissions/troyanorte

How can I submit an appeal and get my account unblocked? I solved all the problems during the contest, but my account was blocked afterward. I would appreciate it if you could review my case and explain the reason for the ban. Thank you.

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

    New to codeforces and solved all the questions in a div 2? Lol

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

      Do you think this can't be real? The main problem is that I did not receive any notifications and I do not understand the reason for the ban. How can I appeal the decision to block my account?

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

        all odds are against you, this is a very clear sign of cheating. if you really want to clear your name i'd suggest taking a screencast of you doing the next contest

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

what was question D man it was genuinely tough atleast try to sympathise us and give a little easy

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

Good Round, take me to Specialist again!

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

Oh no, I didn't realize that resubmission doesn't count toward the first solve. Missing the first solve of F because of this :(

»
2 months ago, hide # |
 
Vote: I like it -11 Vote: I do not like it

Dear codeforces

I want to sincerely apologize for my actions in this contest. I didn't think my cheating would have consequences like this.

I have learned my lesson from this time. I feel I deserve to be punished for this, but in my account i have a lot of course about coding, so i hope i will be forgiven for my actions to continue practice (and skipped all my submission in this contest to roll back my rating).

I promise I won't join any contests after and will only use my account to practice

Against, I apologize for my actions last week, and I knew rating isn't important, it's just a number

Thank you for your understanding, and I look forward to practicing more on Codeforces

Thanks a lot, have a good day!

(Sorry for my bad English)

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

Well, this afternoon I recieved a message from the system that tell me my submission for D2 was similar to many others submissions, and all of my submissions got skipped. So I was about to write a message to the Codeforces team since I have concrete evidence that can prove I wrote my code (with logs and the idea for the problem was kinds of classic and identical) and the reason my code seems similar to many others is because I used the segment tree template from VNOI Wiki, a published educational community of competitive programming(see this: https://wiki.vnoi.info/algo/data-structures/segment-tree-basic.md). But after a while I realized my submission verdicts changed from skipped to Accepted again, while some of the other's in that message still got skipped. Of course I don't have any problems with this=)))), just being curious what exactly happened? Did they kind of doubled-check or something like that? And do I need to do anything else to prove to the Codeforces team that I wrote the solutions myself?

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

Hi, my submissions are marked as skipped and my participation shows Out of Contest. I received a similarity warning but i wrote my solutions independently in vscode(i can provide timestamps) and did not share or use anyone else code.

Also, the warning seems to reference my own submission ID as a match, which looks unusual. could you please clarify the reason or this and review the case?

Thank You.

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

Subject: Appeal for Plagiarism Warning — Problem 2247D1 (Template Coincidence)

Hello contest admins,

I am writing to politely request a manual review of a plagiarism warning I received for problem 2247D1. My submission (383347453) was flagged as significantly coinciding with submission 383369119 by user 12345678raaz.

This similarity is entirely coincidental and might be due to the use of a template. I usually keep a template of the type of pattern questions. I don't know how it coincided with the other person because I don't even know that guy. Also I don't even know if he is from the same country or not.

Could you please manually review the submissions? I am confident you will see that the overlapping sections are strictly boilerplate code.

Thank you for your time, hard work on the platform, and understanding.

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

Thanks everyone for participating in Codeforces Round 1111(Div. 2). Although it was initially difficult to understand from the editorial when I first participating in Codeforces contests. However I found that once I got used to it, the explanations felt very easy to understand, accurate, and highly academic.

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

Hiii everyone i am looking for friends that will put me through and you know just chill. I really want to get better so if you feel you could help me with that i'd appreciate it

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

Upvote me

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

During the recent Codeforces Round 1111 (Div. 2), I noticed that the code of user DancingInTheLight shows signs of being written by two different people or of using an LLM. Specifically, in problems D1, D2 (383370496, 383373125), he changed the entire algorithm within just 6 minutes, and the subsequent code uses long, uppercase variable names, so I strongly suspect it's AI code. I sincerely hope that the administrators MikeMirzayanov, awoo, KAN, and the contest organizing team makrav will permanently ban this user.