-firefly-'s blog

By -firefly-, 3 months ago, In English

Hello, Codeforces!

After years of hard work, we are euphoric to invite you to participate in Codeforces Round 1077 (Div. 1) and Codeforces Round 1077 (Div. 2), which will be held at 29.01.2026 17:35 (Московское время). For both divisions, you will be given $$$7$$$ problems and $$$3$$$ hours to solve them. For at least one of the divisions, one of the problems will be divided into two subtasks.

The problems are invented and prepared by Bronya_H, Error_Yuan, StarSilk, Tobo, __baozii__ and me.

We would like to thank:

The score distribution is below.

Div. 1: $$$750 - 1250 - 1750 - 2000 - 2250 - (2000 + 3500) - 3000$$$.

Div. 2: $$$500 - 1000 - 1500 - 2000 - 2500 - 2750 - 3000$$$.

We sincerely hope you can enjoy the problems. Good luck and see you on the field !

Bonus

UPD1: The hacks are disabled for problems A-D in Div 2, and for problems A-B in Div 1. We have final tests consisting of pretests and hacks for all problems.

UPD2: Editorial

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

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

First!

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

As a participant, I believe this round will be the most exciting one.

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

As not a tester, neither of these contests will require the ability to speak Chinese to AC

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

I love __baozii__ and -firefly- and fatalerror so much that I’d even have their babies!

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

I participate div2 at the first time...

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

No 6-7 meme this time :(

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

My honor to participate in testing work again with those brilliant coordinators and testers. GLHF!

PS: A photo of __baozii__ and -firefly-:

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

As a tester, I wanted the authors' QQ numbers.

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

0x3F orz !

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

The hype for -firefly-'s crossdress cosplay is real!

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

As a Ruby tester, I have no idea for using Ruby.

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

Tester. A wonderful round, enjoy it!

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

Chuffed to be a tester. A meowvelous round. Hope you find the problems as sweet as an apple : )

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

As a tester, I wish everyone good luck! :)

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

As a participant, i really hope to reach CM

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

Good luck everyone!

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

excited

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

Tester list bigger than my solved list.

Cry knows what's coming GL, everyone. I hope it goes well!

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

ready to hopefully inch closer to pupil!

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

.

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

As a tester, I lose the chance to acheive grandmaster.

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

Hello!

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

Huge respect to the setters and testers. Excited for the round

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

The score distribution will be announced later, along with my crossdress cosplay photograph.

![ ](thats it your putting maid outfit)

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

what am i doing here?

How to be a part of this?

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

As a tester, I think that problems are interesting, have fun!

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

Glad to become one of the testers for this round! I wish all participants GL and HF!

Spoiler
»
3 months ago, hide # |
 
Vote: I like it +39 Vote: I do not like it
  • cry for inventing a basement of infinite capacity

As a tester, I know that he just moved all cheaters on room $$$n$$$ ($$$\forall n \in \mathbb{N}$$$) to room $$$2n$$$ on his last coordinated contest.

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

I hope it goes well.

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

Hope this round deserves an emerald upvote.

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

As a participant, i really hope to reach Expert

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

Good luck everyone!

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

Orz

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

time came to enjoy specialist rank again i guess

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

GLHF!

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

is there late registration ?

»
3 months ago, hide # |
 
Vote: I like it -38 Vote: I do not like it

SSerxhs StarSilk Error_Yuan My account Jin-li-han was disabled mid contest, i had provided clarification for my fast solves for A,B,C to the authors which was due to my laptop crashing and disconnecting from the monitor due to the new nvidia drver updates. for which i had to do a clean reinstall and restart my laptop. in the time being i had paper solved A,B,C and had started on D, I fell i have been banned because it was my first cf contest. however if you have any issues regarding my solutions or any suspected ai use i am more than happy to provide my workproduct and thought process if it is simply becuase of me being a new account i request the ban be reverted for this is unfair towards me. i have not used ai or any other external resources or done anything which violates in contest rules. kindly look into this

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

This is only my 3rd contest, and I haven’t been able to solve a single problem in this one. Does anyone have advice on how I can improve?

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

    You should practice more 800-1200 rating problems and vp div 3,div 4,div2edu to improve yourself,div 2 is a challenge for you now and they are relatively easy.Pick up the algorithm you can't figure out when working through practice problems.

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

      I don't think div2edu is easier than div2...also I think learning basics is more important

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

        what are the basics?

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

          I think like simple greedy, dp, search, and data structures.

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

          Also some necessary math knowledge.

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

        Honestly, I’m not sure what problems to practice. I usually go to the problemset, filter by 800 rating, and start solving. If I get stuck, I try for another 15 minutes, but often still can’t solve it. I’ve only been on Codeforces for about 10 days, and I’m trying to practice every day as much as possible. Do you have any other suggestions? It would really help me a lot.

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

    Follow cp 31 sheet by TLE eliminators

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

Problems are so bad. SpeedGuessForces.

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

Fun fact on Div1D: You need to remove duplicates before take the modulo of each cool number.  I hate pretest23, letting my score minus about 200.  And why Chinese round don't have super large samples on data structure problem. I continue getting RE TLE MLE on Div1C.

»
3 months ago, hide # |
 
Vote: I like it -14 Vote: I do not like it

Huhh!! Sort of GuessForces, and I just suck at bitmask DP

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

Nice Div2B

Enjoyed the contest!

»
3 months ago, hide # |
 
Vote: I like it -24 Vote: I do not like it

F1 should never exist in any contest.

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

Seeing the trend from last 4 div1 rounds; one can probably bet on the fact that next Div1 round would also contain a problem on Trees.

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

look forward to the tutorial

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

so excited to see editorial for E didn't solve it for almost 2 hours

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

Amazing experience really good problems

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

F2 is an old ICPC india regional problem, but constraints were cubic.

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

The idea of my solution of problem Div2D\Div2B (I realized it too late sadly :( )

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

    Yeah I observed that too by brute forcing over all p and q , but how to find the appropriate p and q? Any hint pls

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

      Think of brute force then try to optimise it using dp.

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

      I'm not sure if what I wrote are hints or the actual answer, but read them and try to implement them by yourself ^_^

      for the second and fourth cases

      Spoiler

      for the first and third cases

      Spoiler

      I hope that you found them useful ^_^

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

    Bro I do same but still wrong answer, can u check

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

      your way to find the lesser number is correct

      but your way to find the higher number is not always true

      if I have the number 12, in binary it is 1100, let's say that the next higher number is 1101, while your solution finds that the higher number is 16 10000

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

    Wow, i regret looking at the tests more carefully :'(
    Took >3hours and lots of debugging to implement this case based approach.

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

    I was doing ,

    If the bits of x and y is different then we can take the bit's of x in p as it is and same for the y bit's in q as it is ,

    but if they are different we have to make either q's bit 1 or the p's bit 1.

    But couldn't come with a dp solution during contest otherwise would have been my first div2 D.

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

How do you solve div2 D ?

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

    My guessforces answer is as follows:

    we can guarantee x will remain unchanged or y will remain unchanged..

    can you greedily find the other number such that the abs difference is minimal and & is 0?

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

That was a excellent contest ! Thanks

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

editorial??

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

wonderful contest to be honest

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

Pretty easy and previously seen question b was seen as div3e somewhere in past splitting across 1 c was pretty easy simple two elements can make it at right position idk I found a more difficult than usual a's

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

There’s no way we got more than 7000 ac in div 2 problem C

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

QAQ

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

So, the Indian guy at the top of the ranklist(div 2) has 6 compilation errors and 10+ WA on pretest-1 in just a single contest? Definitely not a cheater I guess.

»
3 months ago, hide # |
Rev. 8  
Vote: I like it +6 Vote: I do not like it

Cool problem C! I did(n't) solve it during contest, but its solution is actually very satisfying. The first thing I noticed is that there's monotonicity in k (if k+1 works, so does k). "Ok", I thought, "perhaps I'll use that later." So I set that fact aside and continued thinking.

(1) Then I considered how swaps work and if I could somehow exploit the condition. I noticed it's possible to swap (x, y) using some other z such that z stays in place. This would contribute min(abs(x-z), abs(y-z)) instead of abs(x-y). Seemed useful enough.

(2) Another idea I had was to treat this array as a graph and add edges between nodes (array indices) if their values had an absolute difference >= k. That is, if I were to binary search.

Since I did not see how to put to use (1), I decided to follow the advice of a wise man I once learned. "All you need is randomly guessing."

(3) So I guessed that if I grouped nodes from (2) together (union-find), it would be possible to somehow sort them within these groups. Also, notice we do not need to merge all of them. It's enough to merge a node x with min (instead of some prefix) and max (instead of some suffix) (when possible).

And... it WA'd. Only after the contest did I realize why. I set my right binary search bounds too low! I forgot I wasn't dealing with a permutation! Ouch!

So after the contest I had a conversation with my friend NekoIie, who arrived at this powerful observation: k=min(k, max(abs(a[i]-min_element(a[])), abs(a[i]-max_element(a[])) among i that are missplaced. This is to say that it's always optimal to swap with either max or min in the array.

I did miss that! And then he pointed me to the right construction. Imagine we are binary searching (in the end we can ommit this). Find the positon of a[i] in the final sequence (denote the element present there currently as mp(i) (short for "mapped"). Break ties in some sensible way. For some fixed k, we will traverse the array a[] and (skip i if a[i] is already in the right place) if it's possible to swap, do so. Otherwise, try one of the following constructions: (A) use min to swap (i, mp(i)). (B) use max to swap them. (C) use min AND max to swap them.

constructions are here

So, in the end, we always pick either min or max for some i and perform the swaps. This also proves the approach described in (3). Because there will be some middle part left out and a connected component of some prefix and suffix. I wish I went a step further during my attempt at solving the problem and considered the implications of my idea. At the very least, I'd write a shorter check() for my "magically" working solution!

This comment is meant to serve as a reminder that among all the moving bits and pieces in a problem, it's always useful to first try find elements that don't change much, that are maximal or minimal in some way. After you "grab" hold of them, try to reason and progress from there. That helps a ton. It's fairly similar to solving math problems with invariants and monovariants. A different wise man once said "when solving a problem try to think of the smallest sensible step that could lead from your current position to the solution". Because solving a problem is like fiding the right path through a graph (of ideas).

360627538 — the clever construction (could be written even more concisely, since after all, you just pick to swap with min or max, also one (abs(y-x)) of the max terms could be removed, it's never worse to not use it and I should probably mention that I don't actually do the swaps in a[], although it could be done, works regardless)

360628478 — corrected random guess here

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

We can solve d2D/d1B using simple greedy method!

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5

My submission: 360631214

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

https://ibb.co/1tvfLNrM How is this possible? I dont get it

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

Enjoyed the contest !. Though i solved AB during the contest, After giving a thought to the C, I regretted because i solved B very late and had i got more time during the contest, i could have cracked the C one. I think i need to keep my practice high so that i don't just solve the problem but solve in less time as compared to my competitors !.

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

honestly the tasks are difficult

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

Let's go, one point away from expert

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

Задача G никто не мог решать

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

First!

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

hello

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

when will the editorial be released?

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

breh

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

Good round!

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

I am not first!

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

(deleted)

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

deleted

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

this round learnt that short problem statement does not mean problem is easier..

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

If anyone wants a dp solution for div 2 D :Problem Link

Here is my code:{If explanation needed , ping me} .


int dp[35][4][4]; pair<int,int> best[35][4][4]; vector<pair<int,int>> choice={{0,1},{1,0},{0,0}}; int vis[35][4][4]; int timer=0; int x,y; /*0->equal , 1->less,2->greater*/ int rec(int level,int ps,int qs){ if(level<0) return 0; if(vis[level][ps][qs]==timer) return dp[level][ps][qs]; int ans=1e16; int x_bit=((x&(1LL<<level))>0?1:0); int y_bit=((y&(1LL<<level))>0?1:0); int val=(1LL<<level); for(auto &[p_bit,q_bit]:choice){ int new_ps,new_qs; int cost=0; int p_cost=(x_bit-p_bit)*val; int q_cost=(y_bit-q_bit)*val; if(ps==0) cost+=abs(p_cost); else if(ps==1) cost+=p_cost; else cost-=p_cost; if(qs==0) cost+=abs(q_cost); else if(qs==1) cost+=q_cost; else cost-=q_cost; new_ps=(!ps?((p_cost>0)?1:2):ps); if(x_bit==p_bit && !ps) new_ps=0; new_qs=(!qs?((q_cost>0)?1:2):qs); if(y_bit==q_bit && !qs) new_qs=0; int temp=rec(level-1,new_ps,new_qs)+cost; if(ans>temp){ ans=temp; best[level][ps][qs]=make_pair(p_bit,q_bit); } } vis[level][ps][qs]=timer; return dp[level][ps][qs]=ans; } int p_ans,q_ans; void genrate(int level,int ps,int qs,int &p,int &q){ if(level<0) return; auto &[p_bit,q_bit]=best[level][ps][qs]; p|=(1LL<<level)*p_bit; q|=(1LL<<level)*q_bit; int n_ps=ps,n_qs=qs; int x_bit=((x&(1LL<<level))>0?1:0); int y_bit=((y&(1LL<<level))>0?1:0); if(ps==0){ n_ps=(p_bit>x_bit?2:(x_bit!=p_bit?1:0)); } if(!qs){ n_qs=(q_bit>y_bit?2:(y_bit!=q_bit?1:0)); } genrate(level-1,n_ps,n_qs,p,q); } void solve(){ cin>>x>>y; timer++; p_ans=0,q_ans=0; int ans=rec(32,0,0); genrate(32,0,0,p_ans,q_ans); cout<<p_ans<<" "<<q_ans<<'\n'; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t=1; cin >> t; while(t--){ solve(); } return 0; }
»
3 months ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

Please Eliminate NguyenQuyetDinh2.cpp

He cheated in last round

The F's submission https://mirror.codeforces.com/contest/2188/submission/360593590

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

Good Very Good

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

Hi, coordinators

A coincidence warning was sent to me regarding issue 2188C (contribution 360598939).

I did not steal anyone's code, did not share my code with anyone, did not use public online IDE with open access.

The code appears identical because several participants (including me) independently adopted the same faulty greedy idea:Calculate the overall minimum and maximum. - if sorted already → -1 If not, take min over max's misplaced places (a[i]-L, R-a[i]).

When you mistake or misunderstand the swap condition, this is a perfectly natural incorrect thought. apart from that my code snippet is like that in this particular maximum part from the snippet. You can observe that numerous false submissions on B have almost the same format. I have submitted 5 wrong submission for b three before and two after submitting the c i have to copy i would have done it for b before doing c it's just that the solution clicked me.

This, in my opinion, is an instance of numerous individuals making the same error on their own.

Please check / cancel the warning if feasible.

I'm grateful!