FelixArg's blog

By FelixArg, history, 12 months ago, translation, In English

Neapolis University Pafos

Hello Codeforces!

The series of Educational Rounds continues thanks to the support of the Neapolis University Pafos.

On Jun/03/2025 17:35 (Moscow time) Educational Codeforces Round 179 (Rated for Div. 2) will start.

This round will be rated for the participants with rating lower than 2100. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest, you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 6 or 7 problems and 2 hours to solve them.

Almost all of the problems in the round were invented and prepared by me. I would like to thank Ivan BledDest Androsov for the problem that made the round more balanced.

And once again, I would like to express my sincere thanks to the round coordinators: Ivan BledDest Androsov and Mikhail awoo Piklyaev for improving the quality of the problems and helping with their preparation.

And of course, huge thanks to Mike MikeMirzayanov Mirzayanov for great systems Polygon and Codeforces.

Good luck to all the participants!

Our friends at Neapolis University Pafos also have a message for you:

Admission to the Computer Science and Artificial Intelligence Bachelor’s program at Neapolis University Pafos is ongoing!

The JetBrains Foundation is offering 20 fully funded scholarships for talented first-year students.

Each scholarship covers the entire duration of the program, including tuition, accommodation, medical insurance, visa fees, and €300 per month for personal expenses.

Find out more about the CSAI program →

Good news! If you missed the first round, there’s still time to apply for the second round! Submit your documents, pass the entrance test and interview, and receive a full scholarship.

  • Application deadline – June 11, 2025
  • Entrance test – June 15, 2025 (this is the last entrance test for 2025!)

Additionally, there are 2 fully funded scholarships available for students wishing to transfer into the second year of the program (for those already studying Computer Science).

If you have any questions, feel free to ask in the Telegram chat or email us at nup@jetbrains.com !

UPD: Editorial is out

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

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

Hoping that problems will be very easy so that I can reach Master)

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

Hoping for 2000 rating even though 2000 rated problems are killing me nowadays

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

Hoping that problems will be at a decent level maybe theoretic , so that I can reach Pupil :)

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

Hoping that the problems won't accept bruteforce solutions this time.

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

I'm out of competition

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

    Thank God I became Master already, solved A-E in a little more than 1hr and didn't even got top 100 trusted participants div 2 (considering I was competing in div 2 with exact same performance). Too many sweats nowadays

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

      months of edging

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

      I saw your submission for E, and I'm failing to see any logical difference from my one of my own attempts 322744022 yet I got WA, would you know what am I doing wrong?

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

      lmfao forget it i just saw my mistake, i never expected there to be operations like a a, b b and c c, and because of that i'm inserting some wrong stuff into my sets, what a dumbass mistake lol

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

        If the check c -> b -> a fail it should still do c -> b if possible


        } else if(!cb.empty() && !ba.empty()) { auto it2 = ba.lower_bound(*cb.begin()); if(it2 != ba.end()) { s1[i] = 'a'; cb.erase(cb.begin()); ba.erase(it2); } } else if(!cb.empty()) { s1[i] = 'b'; cb.erase(cb.begin()); }

        Check this minimal counter example:

        1  
        1 2
        c
        b a
        c b
        
        • »
          »
          »
          »
          »
          12 months ago, hide # ^ |
           
          Vote: I like it +8 Vote: I do not like it

          yeah I did that as well on 322751333 during the contest, and for this one the only missing thing was handling the repeated character operation. Unfortunate! I might have missed my chance to get Expert for the first time :/

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

            I was not expecting repeated characters as well, I naturally avoid using else when programming because it's supper prone for missing edge cases, I'd rather have everything explicity. Anyway, you will have plenty opportunities ahead to become expert, just keep practing

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

              hey, I don't understand why am I getting TLE on this submission for E 322816931 even though the time complexity is O(nlogn). Could you please check it.

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

                lower_bound(s.begin(), s.end(), value) is O(n) s.lower_bound(value) is O(log n) for set.

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

'

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

why there is a lot of femboy in cf?????

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

Hoping that problems will be interesting!!!

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

I hope there are educational problems rather than some constructive permutations problem__

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

    Agree. We need educational round not permutation round or super Ad-hoc round.

»
12 months ago, hide # |
 
Vote: I like it -27 Vote: I do not like it

Its clashing with IPL Final

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

all the best to everyone

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

glhf everyone

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

Have a good one folks

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

why it is showing when i try to login with my other account "User is Disabled"

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

Can't solve E, get -ve delta again :(

upd: My idea was correct, but when it couldn't pass sample, I mistakenly thought it was wrong and discarded it:(

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

    I think lot of people got WA, even though they had the correct idea. I think they could have included stronger samples, but then that would make the problem too easy I suppose.

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

Awesome contest, thank you for making such a contest!

problem $$$E$$$ was so cool in my opinion

(I hope to reach CM after the hacking phase ^_^)

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

    Not sure what made E cool problem? I am bit salty bcz I forgot to consider the order and got wa, but wasn't the idea really obvious?

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

I was thinking of 4d dp solution for div2B for hours , then looked at picture provided got the answer in seconds

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

Why were all the problems upto D of such a low quality(I mean gpt-able) a cheater can easily skim through A to D using AI ;)

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

Order should be C,B,A instead of A,B,C

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

Perfect contest. Thankyou <3

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

how to solve D? zig-zag is optimal right?

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

    Be careful when $$$n$$$ is odd, then it's right

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

      lets say we are given (A,B,C,D) (sorted) then which pair is better ? A-C,B-D or A-D, B-C?

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

      I didn't have to handle this edge case in my solution

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

        The first group starts at the bottom and then goes to the top and keeps repeating. The second group does the opposite of the first: it starts at the top and goes to the bottom and keeps repeating. The the next two groups do the same with second highest classroom and second lowest classroom and so on. My implementation looked like this:

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

      bruh this was causing problem got AC now

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

    pick $$$\lceil n/2 \rceil$$$ lowest classrooms and $$$\lceil n/2 \rceil$$$ highest classrooms

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

I spent 30-40 minutes debugging my code for C to finally get to know that I had set the initial value of the ans to INT_MAX which should've been greater than that :( Could've gotten positive delta this round

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

    dude omg same

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

    I also did same mistake although I have habit of writing LLONG_MAX , this time in hurry I wrote INT_MAX , figured out in 10 mins though , but this small mistake caused additional penalty of 30 shh..

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

A-D Div3.5

E+ Div 2

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

probably the hardest pair of A and B i ever saw in contest, and then C and D were pretty easy, while E was an okay problem and F seems really cool but wasted too much time on stupid WAs on E :C , cool round overall

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

Could anyone help me to figure out why this submission went wrong on test 4 of E? I had an idea of considering this problem to parenthesis matching: consider c->b->a as ( for c->b and ) for b->a, and b->c->a as [ for b->c and ] for c->a. And I greedily sweep the string, try to convert chars into a in priority. I use ] or ) in priority and split matched parenthesis into ( or [ if no single ] or ) exists. So could someone tell me why I got wrong in E :(

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

    are you doing '(' when ')' does not exist after '('?

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

      Yes I did in submission:

      ...
      else if (c == 'c'){
            if (direct_ca > 0){
              direct_ca--;
              c = 'a';
            }
            else if(match_cba > 0){
              match_cba--;
              c = 'a';
            }
            else if(match_bca > 0){
              match_bca--;
              c = 'a';
            }
            else if (direct_cb > 0){
              direct_cb--;
              c = 'b';// convert to `b` here
            }
          }
      ...
      

      I tried to convert to a if possible, then I will try to convert into b

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

        else if(match_bca > 0){ match_bca--; c = 'a'; }

        why are you doing this? in c=='a'

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

          I converted c into a and spilt b->c->a, for greedily conversation for lexicographic.

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

            what? i don't understand, how are we greedily choosing bca when s[i] = 'c'

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

              Sorry I had compared the output from the accepted code from ranklist and I found the glitch, since you reminded me the way to choose the "matched parenthesis". Here is a hack input:

              1
              5 10
              bbccc
              b c
              b b
              c a
              c b
              a a
              b a
              b a
              a a
              b c
              c a
              

              And the answer is aaaab, but mine got aaaac.

              The cause of wrong answer is that I used match_bca in priority instead of match_cba, which would waste a chance for converting c to b. When I swapped this two branch, I got accepted :)

              Thanks for your time sincerely for reminding the possible problem exists :)

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

    You have paired c-> b and b->a and only use the remaining b->a for direct conversion of b to a. What if the string has many occurences of b in the beginning? And since you paired up your moves you don't have enough b->a left to make the lexicographically smallest string?

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

      I will spilt the matched conversation if necessary, and c->b will restored as unmatched

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

        What you're doing isn't greedily optimal. Suppose that you used 1 match_cba for a conversion of c->a, and then 1 match_bca for a conversion of b->a. Now if there were only 4 operations:

        1. c b
        2. b a
        3. b c
        4. c a

        you will have no operations left. However, it is possible to just use 4th operation to convert c->a and 2nd operation to convert b->a. The remaining operations can still be used to convert 1 c to b.

        Testcase where your code fails:

        1 $$$\newline$$$ 3 4 $$$\newline$$$ cbc $$$\newline$$$ c b $$$\newline$$$ b a $$$\newline$$$ b c $$$\newline$$$ c a

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

how to solve D ?

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

    sort all classrooms based on ClassroomID/100, then pair up each class (you can adjust if n%2==1), then for each pair i, you are gonna give them the classrooms i and n-i-1 (i is 0-indexed, and this is after sorting the classrooms). and those 2 classes will just keep switching between those two classrooms, do this for all pairs. if n%2==1 just make sure you dont overflow since it wont have a pair. you can check my impl for details

  • »
    »
    12 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it
    for(int i=0;i<n/2;i++){
                int mini = cls[i];
                int maxi = cls[m-i-1];
                cout<<mini<<" "<<maxi<<" "<<
                mini<<" "<<maxi<<" "<<
                mini<<" "<<maxi<<endl;
    
                cout<<maxi<<" "<<mini<<" "<<
                maxi<<" "<<mini<<" "<<
                maxi<<" "<<mini<<endl;
            }
            if(n&1){
                int mini = cls[n/2];
                int maxi = cls[m-n/2-1];
                cout<<mini<<" "<<maxi<<" "<<
                mini<<" "<<maxi<<" "<<
                mini<<" "<<maxi<<endl;
            }
    
  • »
    »
    12 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Zigzag pattern, sort the classes, now observe each group will oscillate between two classes only(group 1 and n will oscillate between classes 1 and m, group 2 and n-1 will oscillate between classes 2 and (m-1) and so on) Be careful for middle group when n is odd and if sufficient number of classes are available to oscillate the middle n.

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

    Hello Tausif

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

D is much easier than it should be.

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

    well I guess Im just stupid then

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

    Agreed, I solved ABC and left the contest, as I have never solved D in a contest before, but came back and it was pretty solvable.

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

      i wasted the whole 1hr 30 min left after C to overthink on D. Only now have I realised how simple it was lol could have got a really high delta :(

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

I don't know why less people solve D as compare to C, because D was just normal sorting. Although C was also very easy.

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

    Maybe because of its big numbers or because most of us think D is much harder than C!

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

Very misleading D

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

I've got tricked by problem D :(

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

Guessforces!

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

C<A<E<D<B

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

didn't feel like an Edu Round. Bar is too high for Edu Round than today's.

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

okk...D was simple zig zag, i don't know why i did some complicated zigzag.

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

Problem E  

we have to find a minimal lexicographical string by applying operations where each character transitions to another character at certain positions.

  1. Represent each operation as a directed edge x → y. Goal: find the lexicographically smallest letter each character can reach.
  2. Compute transitive closure of the graph and get the minimal reachable letter for 'a', 'b', 'c'.
  3. For each character in s, replace it with its minimal reachable letter to minimize the string.

 

  1. Define function $$$D_{q+1}(\ell) = \ell$$$ for each $$$\ell \in {a,b,c}$$$.

  2. For $$$j = q,\,q-1,\,\dots,\,1$$$ and each $$$\ell \in {a,b,c}$$$:

$$$ D_j(\ell)= \begin{cases} \min\bigl(D_{j+1}(\ell),\,D_{j+1}(y_j)\bigr), & \text{if }\ell = x_j,\\ D_{j+1}(\ell), & \text{otherwise.} \end{cases} $$$
  1. The final string is $$$\bigl[D_1(s_i)\bigr]_{i=1}^n$$$.
»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I think D's first sample is very misleading, but the third sample redirected me back to the correct solution

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

can someone help me in finding the mistake here?

https://mirror.codeforces.com/contest/2111/submission/322754971

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

    My submission for E, wrong on 2nd test case. 43rd words differ. I wish I could know what that test case was!

    first, i keep track of all b and c. if b — a , i do it. Same for c — b.

    if b — c, i keep a counter, gonna need it if i find c — a.

    for c — a, if b — c counter positive and that b's position is smaller than current c, then that b will be a. (via b -> c -> a). Otherwise, just convert earliest c to a.

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

I started the contest really slowly cuz I was doing it during a class lol. Luckily I bounced back with D and E afterwards by just being brazen with it. btw, for anyone looking for a tutorial on E, this is all I wrote down and it worked:

Notes on problem E

Note that you still need to be careful as to removing the first or last occurrences of each type of operation as you use them, keeping track of them in a map/set or similar.

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

    How do you make sure that turning b to a before turning c to a does lead to the optimal solution, since these two operations share "b -> a" and "c -> a"?

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

      The idea is that we are going to process from left to right, greedily trying to make the current letter as small as possible. If the operations "b->a" and "c->a" are both present in the q given operations, they can be done in either order, it shouldn't matter. We will do whatever we need to at the current letter to make it small since that is worth more than making later characters smaller instead.

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

    can you look at my submission please, I tried to implement the same idea.

    Submisssion

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

D is too simple, even simpler than B, this makes me confused, thinking if there exist any special cases and thus i wasted a lot of time.

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

Can someone please help with problem A.. Not able to solve it

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

As a newbie i felt B>A>C.

  • A: took more time than i expected it would, although i was a little late to start the contest.
  • B: Was very interesting, once you notice that after stacking the largest two cubes the other cubes always fit in some fashion, This was actually shown in the nice image in the Question. (nice authors)
  • C: I imagined this as a islands trying to capture other islands, and that helped, me although at first i had attempted a half cooked approach, which resulted in a -1 in C
  • D: did not get time. :( -signing off, newbie.
  • »
    »
    12 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    Cany you help me tackle A? I am still not able to understand it. Please. Also can you tell me how did you manage to get to 1095 with just 15 problems? Thats insane.

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

https://mirror.codeforces.com/contest/2111/submission/322756208

the hack looks sus... I maybe wrong but still it seems like the solution deliberately wanted to get hacked..

" if(n > 1 && arr[0] == 500000 && arr[1] == 499999) { return void(cout << 249999000001 << '\n'); } int64_t sum = 0; "

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

    The summit is after the end of the contest, just copy the jury´s answer on test 6.

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

I don't know why everyone thinks B was hard? You just had to look at the shape to realize that the first two should fit You just had to look at the Fibonacci sequence of the sides with an inductive view to realize how every ni — ni-1 = ni-2

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

Missed E because of one continue statement.

322745440 322759713

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

322720874, 322745486 what a coincidence!

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

G and https://mirror.codeforces.com/problemset/problem/1887/D are the same problem, except that G is forced online. Change the binary indexed tree of 1887D to a persistent segment tree, then you can get accepted in G.

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

    I 'm sorry, I couldn't find that a similar problem has appeared before.

    However, I hope that this problem will be a good educational challenge on persistent data structures.

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

Problem 'A' seems harder than B,C,D for me. Did anyone feel like that?

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

322764289

MLE in test2 problem D

HELP...........

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

I registered in this contest as rated participant why is it showing up as unrated for me ?

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

I got TLE for 5th case in python 322700139

i don't understand why? There's no more complexity that getting the inputs

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

    now i figured input reading is fukin slow in python. Oh come on god, really

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

      does not look like an input issue (this problem doesnt even have sizable inputs) but rather a string building problem

      building a string like that (+= chars in a loop) is N^2 in virtually any language as you are making a new copy every time

      in py specifically you could use a list of single char strings and do ''.join(arr) after all the appends are done

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

    adding a character to a string of length n is o(n) in python, learnt this the hard way few days ago :)

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

Felt happy solving 4 problems... only to see 3500+ people ahead even on the day of the IPL final!!!

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

GreedyForces

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

EDUCATIONAL GREEDY-FORCES ROUND

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

How to solve problem F

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

    Here is the idea I implemented. I'd be very curious to see whether other people came up with different solutions!

    The first step is to find a general source of constructions: Start from a square of side x (so perimeter 4x, area x^2), and remove some squares from the top right. This does not change the perimeter but decreases the area, giving a construction for p = 4x, and 2x-1 <= s <= x^2.

    For the given p and s this probably won't work (for one, the perimeter might not be a multiple of 4). However, note that you can scale p and s up by the same factor. We can make the above construction work for pk, sk as long as|

    • k is a multiple of 4
    • p/2 <= s
    • s <= (pk/4)^2

    and it turns out that if p <= 2 s, k = 200 should always work.

    Finally, we need to decide what happens when p > 2s. For instance, with just one square we can achieve p = 4 and s = 1, while there are other situations that are not solvable.

    Suppose we have a polyomino with perimeter p and area s. It is not hard to observe that p <= 2s + 2: indeed, equality holds when there is only one square, and each time we glue an additional square, we add 4 edges to the total, but glue 2 together, contributing at most 2. Moreover:

    • When p = 2s+2 we can just place s squares in a line.
    • We cannot have p = 2s+1, since the perimeter is always even.

    Therefore, when p > 2s in the input, we check whether p/s = (2k+2)/k for some k. If yes we have a construction. If no, output -1.

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

chatgpt can solve F with no input from the user

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

    your code looks very nice! i love how they have so many comments explaining every bit of code. Does using chatgpt help you perform well?

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

      I recently started trying to use copilot yea. I sometimes tell it what to do in a function in a comment and it just does it for me and stuff, if it's simple enough. I am pretty sure copilot is allowed, however. Core logic is all mine and stuff. It is quite sad to see that these AIs are better than me though. I couldn't solve F but it did it so fast...

      A point to consider is that at SWERC Lyon a JetBrains code editor with built-in code completion similar to copilot was allowed, so yeah

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

Should we use different testcases for every hack? why blocked from hacking?

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

Difficulty estimations

A — 800

B — 1100

C — 1200

D — 1400

E — 1800

F — 2200

G — 2500

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

    Clist: 800 — 1100 — 1100 — 1400 — 2000 — 2400 — 3000

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

The problem of the contest were so tricky but i love :)

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

Solution for E, with comments explaining.

#include <bits/stdc++.h>
using namespace std;

// the relevant paths are: c->a OR (c->b, b->a) OR c->b OR b->a OR (b->c, c->a)
// if you find a "c" and you have a c->a somewhere, delete the earliest c->a and change the c to an a
// if you find a "c" and you have a c->b, b->a somewhere, delete the earliest instance c->b and earliest b->a
// if you find a "c" and you have a c->b somewhere, delete the last instance c->b
// if you find a "b" and you have a b->a somewhere, delete the earliest instance b->a

// ALWAYS TAKE c->a over (c->b, b->a) if its on offer. no cost to taking it.
// ALWAYS TAKE b->a over (b->c, c->a) if its on offer. no cost to taking it.

int main(){
    int t, n, q;
    string s;
    char a, b;
    cin >> t;
    while(t--){
        // n characters, q operations inorder
        cin >> n >> q >> s;
        // a->b, a->c, b->a, b->c. c->a, c->b
        set<int> abset, acset, baset, bcset, caset, cbset;
        for(int i = 0; i < q; i++){
            cin >> a >> b;
            if(a == 'a' && b == 'b') abset.insert(i);
            else if(a == 'a' && b == 'c') acset.insert(i);
            else if(a == 'b' && b == 'a') baset.insert(i);
            else if(a == 'b' && b == 'c') bcset.insert(i);
            else if(a == 'c' && b == 'a') caset.insert(i);
            else if(a == 'c' && b == 'b') cbset.insert(i);
        }
        for(char c : s){
            char output = c;
            if(c == 'c'){
                //remove the first ca, to interfere with bc, ca as little as possible
                if(caset.size() > 0){
                    caset.erase(caset.begin());
                    output = 'a';
                }
                else if(cbset.size() > 0 && baset.size()){
                    auto first_incompat_cb = cbset.lower_bound((int) *prev(baset.end()));
                    // remove the very last ba, and the last compatible cb
                    if(first_incompat_cb != cbset.begin()){
                        cbset.erase(prev(first_incompat_cb));
                        baset.erase(prev(baset.end()));
                        output = 'a';
                    }
                }
                if(output == 'c'){
                    //remove the very last cb, to interfere with cb, ba as little as possible
                    if(cbset.size() > 0){
                        cbset.erase(prev(cbset.end()));
                        output = 'b';
                    }
                }
            }else if(c == 'b'){
                // remove the first ba, to interfere with cb, ba as little as possible
                if(baset.size() > 0){
                    baset.erase(baset.begin());
                    output = 'a';
                }
                // remove the very last ca, and the last compatible bc
                else if(bcset.size() > 0 && caset.size() > 0){
                    auto first_incompat_bc = bcset.lower_bound((int) *prev(caset.end()));
                    if(first_incompat_bc != bcset.begin()){
                        bcset.erase(prev(first_incompat_bc));
                        caset.erase(prev(caset.end()));
                        output = 'a';
                    }
                }
            }
            cout << output;
        }
        cout << "\n";

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

322764289

Explain why this submission resulted in the particular verdict.

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

Let me tell you a joke, I didn't write question A for an hour, but I did BCD within an hour, and in the last 2 minutes, I guessed A.

GussForces

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

    How did you guess ?

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

      I observed from the answer and found that the answer is not very large. I tried to calculate that n needs to be divided by 2 several times before it becomes 0, and then found that 2 * cnt+1 is the answer. code

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

        So by some observations you thought and could be 2*cnt +1. Anyone who can explain B

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

          Question B: If the largest cube can be accommodated, then consider whether the second largest cube can be accommodated. If the second largest cube can also be accommodated, then according to Fibonacci's characteristics, the remaining space must also be able to fill the remaining cubes. Observing the picture of Case 1, it can be observed.

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

Why C and E getting hacked too much? , i mean is there a common flaw?

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

why did i not gain any rating i solved A :v

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

Can anyone provide a test case or can tell where this code for Problem C will fail..(Except TLE)..I am not able to figure it out.


#include <bits/stdc++.h> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t; cin>>t; for(int i=0;i<t;i++){ int n; cin>>n; vector<int>arr(n); for(auto &x:arr) cin>>x; map<int,pair<int,int>>pos; for(int i=0;i<n;i++){ if(pos.find(arr[i])==pos.end()){ pos[arr[i]].first=i; pos[arr[i]].second=i; } else pos[arr[i]].second=i; } long long cost=LLONG_MAX; for(auto it:pos){ long long ai = it.first; long long fi = it.second.first; long long li = it.second.second; int flag=0; for(int k=fi+1;k<li;k++){ if(ai!=arr[k]){flag=1;break;} } if(flag==0) cost = min(cost,fi*ai + ai*(n-li-1)); else{ cost = min(cost,fi*ai + ai*(n-fi-1)); cost = min(cost,li*ai + ai*(n-li-1)); } } cout<<cost<<endl; } }
»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I only rate at about 8000,will I be out of speclist(cry

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

I didn't understand the statement of problem A but I guessed the answer

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

For problem E, how is the expected output "b" for following testcase(9th part of 2nd testcase)

1

1 3

c

a b

b a

c b

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

For E, can someone help me figure out why my solution is returning WA on test case 2?

My idea is to 'cache' c-b and b-c for later use, and edit the earliest possible letter in the string when encountering b-a or c-a (at the end I make sure to use all leftover c-b). This works in O(N+Q) for any input I can think of, but fails on the 420th input of test case 2 (which I am not able to see).

Any help is appreciated. Please let me know if you would like clarification on the code.

322827978

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

    your code fails on this test case below

    8 7
    cbaacacb
    a a
    a a
    c b
    b a
    c a
    b c
    a b
    

    Answer should be : aaaabacb

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

    1 4 3 acbc c b b a c a

    your code fails for this input. when you get c->b->a you do it, even though you might get c->a later, which could save you the c->b operation when you might need it later, i think an even simpler input where you can see it is:
    1 3 3 acb c b b a c a

    the problem is that you solve it online, when you should consider all the operations first and then start using them

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

My Code.

Could anyone help me debug this code? I've been debugging for five hours but made no progress. I would be extremely grateful if you could take a look.

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

Hi MikeMirzayanov, I noticed my submission is being flagged for similarity with (handle: Ha7NBaTop). Please note my submission was made at Jun 03, 2025 21:28 (ID: 322733209) during Educational Codeforces Round 179, whereas his submission was at Jun 03, 2025 21:50 (ID: 322745226) — 22 minutes later.

Additionally, our codes have different logic and structure, so I don’t understand why mine is considered plagiarized. I kindly request a review of this, as I wrote my solution independently and earlier.

Thank you!

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

Hi MikeMirzayanov,

I recently received a message saying that my submission to Problem 2111D (submission ID: 322725889, handle: shivamcy) was found to be very similar to a large number of other submissions. I’d like to clarify that I wrote the entire code myself during the contest and did not copy or share my solution with anyone.

I’ve been using the same personal template (for fast I/O and vector handling) in all my submissions, which might explain some common structure. Also, since the problem only required any valid solution that maximizes movement between floors, the idea of sorting classrooms based on floor numbers and picking extremes from both ends is pretty intuitive. That’s likely why many of the solutions ended up looking similar, even if written independently.

I didn’t upload or share my code on any public platforms like Ideone or GitHub during or after the contest, and I didn’t communicate with anyone about the problem. If needed, I’d be happy to share more details or answer any questions to help clear things up.

Thanks for looking into this, and I really appreciate the work you do to keep Codeforces fair for everyone.

Best regards, shivamcy

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

Hello Codeforces team, I received a message stating that my solution for problem 2111C (submission ID: 322691374) coincides with many other participants’ submissions. I want to clarify that I wrote my solution independently. The technique I used is based on a method I learned from a GeeksforGeeks blog that was publicly available before the contest. It’s possible that many other participants referred to the same source and applied the same logic, which might have led to this similarity. I did not share my code with anyone, nor did I copy from anyone else during the contest. I also did not use any public IDEs that could have exposed my solution. Please consider reviewing this case. I am happy to provide the link to the GFG blog I used or answer any further questions.

Thank you.

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

    I’d like to clarify that I wrote my solution independently. The problem was a standard type — involving keeping track of group counts and performing forward and backward iterations to maintain a balance or compute totals.

    This kind of technique is commonly used in many competitive programming problems, and I referred to similar patterns on platforms like GeeksforGeeks to better understand the approach. Given that the idea is quite standard, it's entirely possible that many other participants arrived at a similar implementation independently.

    I respect the platform's integrity and did not engage in any kind of copying or collaboration during the contest. I’m committed to fair participation and would appreciate your understanding in this matter.