Блог пользователя wuhudsm

Автор wuhudsm, история, 15 месяцев назад, По-английски

Hello, Codeforces! We're glad to invite you to take part in Codeforces Round 1040 (Div. 1) and Codeforces Round 1040 (Div. 2), which will start on Jul/31/2025 17:35 (Moscow time).

You will be given 6 problems and 3 hours to solve them in both divisions. Some problems will be divided into subtasks.

The problems were authored and prepared by me.

Some problems may be interactive. So please refer to the guide on interactive problems if you are unfamiliar with them.

We would like to thank

Good luck and have fun!

Score distribution:

  • Div.1: $$$500$$$ — $$$1000$$$ — ($$$750+750+750$$$) — $$$2000$$$ — $$$3000$$$ — ($$$2500+2500$$$)

  • Div.2: $$$500$$$ — $$$1000$$$ — $$$1250$$$ — $$$1750$$$ — ($$$1500+1500+1500$$$) — $$$4000$$$**

UPD 1: Editorial

UPD 2:

Congratulations to the winners!

Div.1:

Kevin114514

jiangly

ecnerwala

ksun48

EnofTaiPeople

Div.2:

alaevS

MoriorInvictus

bradley.louie1

kaiboy

Ghammaz-Hassan

  • Проголосовать: нравится
  • +286
  • Проголосовать: не нравится

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +38 Проголосовать: не нравится

As a tester, I solved strictly fewer than 15 problems during testing.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +43 Проголосовать: не нравится

My first compulsory div 1. contest, guess who's going back to expert.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +42 Проголосовать: не нравится

As a tester, I upvoted this blog.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Wishing everyone a great performance!

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

As a tester, I wish everyone an amazing performance.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

As a non-tester, -firefly- tested.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

As a tester, I could not hear any negative feedback from other testers. Besides, I decided to not tell my opinion about this, as I have seen people believe the exact opposite as I tell them my opinion.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +29 Проголосовать: не нравится

As a tester, I pretend to test.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +106 Проголосовать: не нравится

As a VIP tester, the contest is completely different than when I tested.

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    That's for sure, considering you solved 15 problems for 2 sets of 6 problems (which ig will overlap, giving total of ~10 unique problems in a set). So even in the best case it's only $$$\frac{2}{3}$$$ similarity to your experience :)

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Pretty short and to the point announcement.

»
15 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Finally a Div.1 only contest! As a participant, hope that the problems are interesting and may it be cheater free!

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Interactive problem ,oh no

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Wish this round is better than CodeForces Round 1000(Div. 2)!

Anyway, where's the score distribution?

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

Really excited for Codeforces Round 1040! Huge thanks to the authors and testers for their hard work. Best of luck to everyone—let's enjoy solving together!

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +41 Проголосовать: не нравится

As a tester, I'm in Bolivia.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +18 Проголосовать: не нравится

Hope for short problem's statements like the announcement

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Hoping to reach Specialist with this one :)

I hope everyone does good and reach where they want to :)

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

As a tester, I really enjoyed the problems. Recommend to participate.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

As a tester, I completely forgot about this round

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

As a tester, all the best to everyone.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится -26 Проголосовать: не нравится

Oh, Interactive problem?? Free rating for me. 😁 or WA/TLE/MLE hell 😭 💀

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Hope to reach pupil in this round.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

score distribution ??

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

does score distribuiton mean that e1 will be easier than d?

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Oh!! very interesting score distribution for div2D and div2E-1

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hope I can Skip Speicialist and got Expert :(

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hope to get back to expert :(

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

i miss gf ;-;

»
15 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +2 Проголосовать: не нравится

Thank you to all the authors, testers, and coordinators for this great contest! I

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

Another great problemset by wuhudsm. Best CF round I've done in a while!

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Fun problems. Struggled worse on B than D crew.

I think i had the solution for E, but too slow to implement.

My idea was if we have a known opening bracket '(' and known closing bracket ')', we can check up to 9 indices to see if they are '(' or ')'.

The idea is this we query in this format ('(' + index_to_check + '('). It will be 0 if its closing or 1 if its opening.

Now we expand this idea. for the second index we run the same query twice! and for the third 2^2. Now we receive a bitmask of the values that are ')'!

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

I couldn't solve div2D .. I don't deserve to be an expert.

Someone please share the idea behind it.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

just needed 10 more minutes! for c2!

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve div2E1? Please please please

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    My solution was to find an index that I am sure is a '(' and ')' (call the former bra_index, the latter ket_index), this can be done with binary search.

    After finding these indices, query the other indices two at a time (call them i and j):

    ? 8 i ket_index bra_index bra_index ket_index bra_index j

    Essentially, it is asking what f("s_i ) ( ( ) ( s_j") is:

    • When s_i = '(', s_j = '(', the result would be 2
    • When s_i = '(', s_j = ')', the result would be 4
    • When s_i = ')', s_j = ')', the result would be 3
    • When s_i = ')', s_j = '(', the result would be 1

    so you can identify what those two characters are with one query, and in total it would take less than 1000 / 2 + 2 * log(1000) < 550 queries.

    And actually by making the template 's_i ) ( ( ) ( s_j' longer you can identify 6 characters at a time! I think this is the solution to E2 (probably).

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

hint for E?

Could not understand how to get the correct answer in that few queries

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to 1D

  • »
    »
    15 месяцев назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    I'm pretty sure dp[l][r][center][increments] should work?

    It represents the number of ways you can fill [l, r] where [center] is the first element that gets painted black in the range, and it has been incremented [increments] times by stuff outside of the range. To transition, you just iterate on the next element to pick from [l, r] (resulting in the range getting split into 2) and [increments] is at most like 12 or something, so I think it might run in time (?)

    I couldn't properly implement this in ~30mins though :((

    (edit: I don't think this works 🤣)

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I failed with one of the samples but that sounded good to me:

    • first of all, any written number is something small like 12, because from each side you can't place more than 6 guys (first placed on the left blocks all to the left of him and half of the segment between him and target).
    • then you notice that when you put first element, it separates problem into two unused blocks to the left and right of him.
    • each block can't push values outside of it except it's two sides.
    • So you do $$$dp[l][r][push_A][push_B]$$$, where you solve on subsegment and see how much it can push for bigger problems.
    • Now you take some intermediate $$$l \le i \le r$$$ and see how to get $$$a_i$$$ out of left and right blocks sub-pushes:
    $$$dp_{l,r,push_A,push_B} = \sum dp_{l, i-1, push_A, x} \times dp_{i+1,r,a_i-x,push_B} \times \binom{r-l}{i-l}$$$
    • Based on the block you know that one of push-values will increment by one
    • »
      »
      »
      15 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Actually I found my bug and now it just works so I still have to submit but I'm more or less confident in this one.

      Damn, was so close, forgot to copypaste $$$\times \binom{r-l}{i-l}$$$ once. It would be a get to GM round for me

»
15 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +3 Проголосовать: не нравится

In Div1B, how can we prove that the greedy approach of just iterating right to left and moving a position up if it improves the answer is correct?

I guessed that greedy would get AC after seeing the solve count go up that quickly but can't actually prove its correct >.>

Even solving Div1C3 feels significantly easier than proving this to me.

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится +11 Проголосовать: не нравится

    If u look at inversions as value (1, > 1) + (2, > 2) ..

    u can see relation between (i, > i) pairs is either i is below them or above them.

  • »
    »
    15 месяцев назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +16 Проголосовать: не нравится

    I thought of it differently. Consider the number 1 in the permutation -- if I keep it as it is it will always form an inversion with all digits to the left of it but no inversion with any digit to the right of it, and if I flip it then it will be vice versa.

    So, I can greedily choose what to do with 1. Now that all inversions including 1 are taken care of, we can effectively remove it from the array..and now 2 becomes the new 1 and so on..

  • »
    »
    15 месяцев назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    I thought like this

    Say u move from right to left and at some index i, u see that the no of numbers bigger than a[i] on the left is more than the no of numbers bigger than 2*n-a[i] on the left, now changing a[i] to 2*n-a[i] is definitely better

    But what about the numbers in the right -> if those were smaller then those are still smaller so no change else let's say they were smaller but then they were also changed by 2*n-itself so those are now bigger but now even after doing 2*n-a[i] to index i, those number will still remain bigger hence no change again.

    Edit: ok i missed the case where the right number is bigger but then it was made 2*n-itself

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    See my comment above. You can prove this by showing that as the number increases, whether you choose i or 2n-i has NO effect on your previous selections. (1,6),(2,5),(3,4) if you choose 1, it will be the smallest value in the array. If you choose 6 it will be the largest value in the array. This means you only need to consider the indices of the elements with a larger N, because your choice has no effect on previous selections.

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Actually, you can iterate through the array in arbitrary order and it can be easily proven.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится -13 Проголосовать: не нравится

ABC great, D guessforces, E cancer

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +29 Проголосовать: не нравится

I SOLVED D IN THE LAST MINUTE

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

also for me... B >>>> C ... I had template for MST so C was easy peasy.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится -22 Проголосовать: не нравится

Trash round! Every time you put these ad-hoc problems my friend will do them faster than me, otherwise this won't happen. Can't you just involve more algorithms???!!!

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +33 Проголосовать: не нравится

I really liked Div1C, its such a fun problem to think about and optimize.

Also thanks for not making the constraints unnecessarily tight.

»
15 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Here's how I solved div2 E1.

First, let's call the query answer Q. The given string in parentheses is s (i.e., we're looking for s). Let the first character of s be s[1], the second character be s[2], and so on. The length of s is given as n. First objective: Find the index that exactly corresponds to ). If we query a string of length 2 and Q = 1, the string must be () . We'll use binary search to find this.

There are two main cases for string s. 1. Q(s) = 0. That is, the RBS is not in s. In this case, s must be in the form )))....(((. That is, s[1] = ) and s[n] = (. Therefore, we can achieve our first goal. In this case, we achieve our first goal. 2. Q(s) > 0. That is, the RBS is in s. In this case, we can find out using binary search. Let the length of the current string be k. I. Let's query from 1 to k//2. If Q > 0, select 1 to k//2 as a new string and perform binary search again. If Q = 0, II. Let's query from k//2 + 1 to k. If Q > 0, select k from k//2 + 1 as a new string and perform binary search again. If Q = 0, Clearly, Q(s) was greater than 0, but both Qs are 0. This means that the RBS has been truncated by the part. That is, it has been divided into k//2 and k//2 + 1, so s[k//2] = ( and s[k//2 + 1] = ) .

This binary search is repeated until the string length becomes 2. If the Q value is 1, then () is confirmed, and we can use that to determine the indices of (and ). Since it's a binary search, n is at most 1000, so it should take less than 50 attempts to obtain the index. Let the positions of the characters (and) be a and b in the indices obtained this way.

Secondary Objective: Finding the Entire String s Now, we need to find the remaining characters, excluding the already known s[a] and s[b].

We can easily find them by pairing them like this.

The query can be as follows: For s[i] and s[j], whose characters are unknown, The query is as follows: i i j j i j i j i j b

If Q = 7, then s[i] = ( and s[j] = ) . If Q = 6, then s[i] = ) and s[j] = ( . If Q = 1, then s[i] = ( and s[j] = ( . If Q = 0, then s[i] = ) and s[j] = ) .

This way, we can find all strings with a single query, so we can find all strings with at most 500 queries.

After finding all strings in this way, we can combine them and output the answer as !

For n = 3, we need to split them using special logic. First, let n be e, f, and g when n is 3. Q(e,f,g) is used. If If Q(e,f,g) is 0, then g = ( , and e = ). To find f, solve Q(f,e). If Q(f,g) is 1, then f = ( , and if Q(f,g) is 0, then f = ). If Q(e,f,g) is 1, then solve Q(e,f). 1. If Q(e,f) is 1, then e = ( , and f = ). To find g, solve Q(g,f). If Q(g,f) is 1, then g = ( , and if 0, then g = ). 2. If Q(e,f) is 0, then f = ( , and g = ). To find e, solve Q(e,g). If Q(e,g) is 1, then e = ( , and if 0, then e = ).

This allows us to obtain the answer when n = 3. Here it is.

Now, next, let's consider the case where k = 3. That is, when the binary search encounters a case where the length is 3. So, instead of using other logic, let's use this logic. Let e, f, and g be e, respectively. Do Q(e,f,g). If Q(e,f,g) is 0, there's nothing more to do in this interval. Move on to the next interval. (If the current interval was from 1 to k//2, move on to the interval from k//2 + 1 to k. If the current interval was from k//2 + 1 to k, set s[k//2] = ( and s[k//2 + 1] = ) and follow the original logic of terminating the binary search.) If Q(e,f,g) is 1, do Q(e,f). 1. If Q(e,f) is 1, then e = ( and f = ) is . Since we have found the indices of ( and ), we terminate the binary search. 2. If Q(e,f) is 0, then f = ( and g = ). Since we have found the indices of ( and ), we terminate the binary search.

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    damn, was close to getting this and knew binary search was involved yet wasn't confident enough to write up a solution

    thanks for explaining!

  • »
    »
    15 месяцев назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    That was my exact idea with slight difference at the i i j j i j i j i j b part, but my solution keep getting stuck at testcase 8, and I see many other people stuck at testcase 8 too. thus I added this part of the code before my main solution to test something out

        cout<<"? "<<t*2<<" ";
        for(int i = 1;i<=t;i++){
          cout<<i<<" ";
          
        }
        for(int i = t;i>=1;i--){
          cout<<i<<" ";
        }
        cout<<endl;
        int temp;
        cin>>temp;
        if(temp==0){
          while(1){
            
          }
        }
    

    The result I got was TLE on testcase 8 while passing the first 7 testcase, my idea was that if the string s consisted of atleast one "(" and one ")", then s[1],s[2]...s[n],s[n-1]...s[1] will consisted of atleast one pair of bracket, but in testcase8 it contains returns 0.

    can someone explain to me why this might have happened? Thanks

    My tle submission: https://codeforces.me/contest/2130/submission/331853802

»
15 месяцев назад, скрыть # |
← Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

Was trying to hack some solutions (D2B) but it kept giving me invalid input — Validator 'vali.exe' returns exit code 3 [FAIL there is no 1 in a! (test case 1)]

Fixed: Just realized there should be atleast one 0, one 1 and one 2 in the array.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

Anyone know why so loose constraints on Div1A/B? Made me suspect my solution for a while lol.

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    $$$O(n ^ 2)$$$ makes Div1B nicer to implement in several ways by allowing you to just iterate over all positions before / after while applying the greedy as well as trivially calculating the total inversions.

    More cynically (or tbf saltily) speaking, it allows you to think about $$$O(n ^ 2)$$$ dp approaches till you go insane :)

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Does anyone know why this TLEs on pretest 5 for div1E? I spent the last 90 minutes of contest crashing out over this and got nowhere

https://codeforces.me/contest/2129/submission/331856028

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

From score distribution I thought to myself that three subproblems is a bad sign. Surprisingly it was quite reasonable, like you definitely have some advancements to do and it's good to be rewarded gradually here.

Good round. Was really close to solve D,but couldn't figure out one of the samples on the paper in last several minutes — wasn't counting one of the cases.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

It took me a long time to conclude that Div2C was just cycle removal.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone explain the logic behind Div. 2B? Banged my head for over 2 hours but couldn't do it :/

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    To go from start to end, Alice has to traverse every element atleast once so required sum should not be less than the sum of the elements. If it is you don't have to rearrange just print the array. If the required sum is equal to the sum of elements no matter how you rearrange, Alice will go from start to end to achieve the sum. Now, if the required sum is greater than total sum, find the difference. The array always contains 0, 1 & 2. If 0 & 1 are neighbors, Alice can go from 1 -> 0 -> 1 to gain extra 1 so it can cover any diff. Only arrangement left is all 0s at the start then 2s then 1s. With 2 -> 0 -> 2, Alice can get extra 2 and with 1 -> 2 -> 1, Alice can get extra 3. Only positive integer which cannot be formed using 2 and 3 is 1. So only if, the required sum is one more than the total sum this arrangement will be sufficient to prevent Alice from getting the required sum. So only two cases:

    1. If required sum is less than total sum : original array
    2. If required sum is greater than total sum by one : 0s 2s 1s
»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

C > D ?

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

why Question D doesn't come, yoink

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For Div2 C ( Div1 A), why is taking the longest segment starting form a point , wrong ?

Eg. {(1,2),(2,5), (1,5)} then answer can be { (1,5) , (2,5) }

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

[submission:331855822]Why is this incorrect?

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What could be the possible problem if Div.1 C1's pretest 1 got TLE (neither Idleness Limit Exceeded nor Wrong Answer, it's Time Limit Exceeded) and checked that cout << endl; / cout << '\n'; then cout.flush() aren't the issues (https://codeforces.me/contest/2130/submission/331854284)

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +34 Проголосовать: не нравится

Approaching 1C3 gradually is a great experience.Thanks for the author!

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone explain why my div2 E1 doesn't work?

https://codeforces.me/contest/2130/submission/331855065

My idea was same as editorial where you find one '(' and one ')' and my query was s1)(s2))

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In E3 div2, during the last 15 minutes I received multiple denial of judgement verdicts, even though nothing was wrong with my code and I had no idea what's wrong. After the contest, the verdicts changed to WA on 8. How can this be explained? I could have solved E3 during the contest if not for this issue...

»
15 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +5 Проголосовать: не нравится

Solved D using Order Statistics Tree in O(nlogn). The constraints really made me doubt my solution, but thankfully it passed!

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +78 Проголосовать: не нравится

Why was problem E approved, and survived testing phase? I'm quite sure both part of the main idea appeared on codeforces and atcoder before.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

weak constraints C,D div2

why n^2

»
15 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +109 Проголосовать: не нравится

Div1B appeared on CF 12 years ago. And I wrote an editorial for this problem, for some reason.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Done anyone have an idea what could the probable rating of D be? Can't believe my weird solution passed pretests :D Couldn't solve C tho :(

»
15 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I could not find the greedy solution for Div2D/Div1B problem.

Instead, my solution is: iterate elements by value from 1 to n. For each value v, let's say its position is i, then count (using a segment tree) how many positions on the left that have values larger than v. Call this count as L. Similarly, count how many positions on the right that have values larger than v, Call this count as R. If L > R, then keep p[i] = v as it is, otherwise update p[i] = n*2-v.

After we have the final array, count its number of inversions using merge sort.

The idea behind this is:

  • When considering a current value v, if there are more numbers v' > v on the left than on the right, it's better to keep v as it is, otherwise, update v to n*2-v.

  • After visiting v, updating or not updating v', v' > v, does not affect to their comparison: both v' and n*2-v' are larger than v, and smaller than n*2-v.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

While everyone solving Div2B fast and correct with O(n), I'm bricking Div2B with O(n+s)...

Back to pupil boys. CF expert is too hard for me, I'll be happy at specialist and that's enough.

»
15 месяцев назад, скрыть # |
← Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

This is my proof for the greedy solution of Div2D

Firstly, the number $$$p_i$$$ will always be as it is or it will increase to ($$$2*n - p_i$$$), it will never decrease

Let $$$1 \lt i \lt = n$$$ going from right to left

And let all the items right to $$$p_i$$$ be in the optimal case

For the left items of $$$p_i$$$, increasing $$$p_i$$$ will make the number of inversions lower or at least it will keep it the same, so for the next left items, it's always optimal to increase $$$p_i$$$. Let the decrease in inversions be $$$x_i$$$ ($$$x_i$$$ is positive)

For the right items of $$$p_i$$$, increasing $$$p_i$$$ may increase the number of inversions by $$$y_i$$$. But if $$$x_i \gt y_i$$$, the total number of inversions generated by the current item and the previous right items will decrease

So increasing $$$p_i$$$ is optimal for any value of the left items (so, changing them will not affect our choice for $$$p_i$$$), and it's optimal for the current values of the right items (which are optimal in the current case)

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

why is system test not starting?

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Div 2 E1 mistake? ~~~~~

void b_n(int l, int r, int i) { int ans = -1; int left = l, right = r; while (left <= right) { int mid = (left + right) / 2; cout << "? 2 " << i << " " << mid << endl; cout.flush();

int response;
    cin >> response;

    if (response == 1) {
        ans = mid;
        left = mid + 1;  
    } else {
        right = mid - 1;
    }
}

if (ans == -1) {

    for (int j = l; j <= r; j++) {
        a[j] = '(';
    }
} else {
    for (int j = l; j <= r; j++) {
        a[j] = (j <= ans) ? ')' : '(';
    }
}

}

int solve() { cin >> n; bool found = false;

for (int i = 1; i < n; i++) {
    cout << "? 2 " << i << " " << i + 1 << endl;
    cout.flush();
    int k;
    cin >> k;

    if (k == 1) {
        found = true;
        a[i] = '(';
        a[i + 1] = ')';

        for (int j = i + 2; j <= n; j++) {
            cout << "? 2 " << i << " " << j << endl;
            int k2;
            cin >> k2;
            if (k2 == 1) {
                a[j] = ')';
            } else {
                a[j] = '(';
            }
        }

        if (i - 1 >= 1) b_n(1, i - 1, i);
        break;
    }

    if (i == n - 1) {
        a[n] = '(';
        b_n(1, n - 1, n);
    }
}

cout << "! ";
for (int i = 1; i <= n; i++) {
    cout << a[i];
}
cout << endl;

return 0;

}

~~~~~

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

$$$B$$$ was kinda annoying. I had to think for a long time (40 min) before I got the solution. $$$D$$$ was a bit of a guess lol.

Overall good problems, thanks for the round wuhudsm and all testers!

»
15 месяцев назад, скрыть # |
← Rev. 3  
Проголосовать: нравится +8 Проголосовать: не нравится

Sub_acc001 is a cheater 331818606. Please bun this shit

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

did tons of reading errors, rating took a drop but loved the questions

»
15 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

my random dividing got fst in C3 :angry:

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Great contest! I especially enjoyed solving versions of problem C one by one. If I didn't get stuck on D for so long I would get more rating XD

(Though, it seems that most participants were confident about their skill and hopped to C3 at once, which could be a better strategy)

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится +2 Проголосовать: не нравится

    Editorial for C3 isnt clear enough, how did you get this sequence in your code? (1,2,3,5) Like the thinking behind it. Max I could figure out was powers of 2

    • »
      »
      »
      15 месяцев назад, скрыть # ^ |
      ← Rev. 2  
      Проголосовать: нравится 0 Проголосовать: не нравится

      The only important thing regarding "powers of 2" is that the weight of the current one should be larger than sum of previous ones. However, the construction to reach exactly "power of 2" requires too much characters and does not make good use of nested substrings, so we need an alternate construction.

      The construction k * (s[i] + ')') + ')' will result in a weight of $$$\dfrac{1}{2}k(k+1)$$$ with a length of only $$$2k+1$$$. So I just greedily find the longest sequence with such weights and the array in my code are the indices $$$k$$$.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I finally became Pupil φ(゜▽゜*)♪

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Nice problems

»
15 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

wuhudsm How are you checking for that thing in D2D?

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

As a tester, I enjoyed testing and IOI

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится -12 Проголосовать: не нравится

Hello Codeforces team,

I have received a notice about coinciding solutions for problem 2130B. I want to clarify that I have always used the same personal template for every question I solve. You can check the submission timestamps: I submitted before the other users listed in the email.

I have not shared my code with anyone nor used any public platform like Ideone with default (public) settings. I’m also an old user on Codeforces, whereas some of the other accounts seem to have been created just recently—I do not know how this coincidence happened.

Kindly review the submission times, account histories, and other details—I assure you I have not engaged in any unfair practices.

Thank you for your understanding.

»
15 месяцев назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -16 Проголосовать: не нравится

Dear Codeforces Administrators,

I recently received a notification alleging that I was involved in cheating, stating that my code is highly similar to another participant's submission: cly312/331768451 and cybercondor/331828373. After reviewing some of our submissions, I would like to present the following reasons why I believe I should not be penalized:

  1. I submitted my solution 90 minutes earlier than him. After solving the problem, I did not share my code anywhere nor use any online code debugging tools.

  2. In his other submissions in this contest, the code consistently begins with the following segment:

#define ll long long int
#define lld long double
#define pb push_back
#define fori for(int i=0;i<n;i++)
#define fore(i,a,b) for(int i = a; i < b; i++)
#define revfore(i,a,b) for(int i = a; i >= b; i--)
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
using namespace std;
 
bool isprime(int n){
    if(n==1)return false;
    for(int i=2; i<=sqrt(n); i++){
        if(n%i==0)return false;
    }
    return true;
}
vector<int> convertbinary64(int n){
    vector<int> v(64,0);
    int i=0;
    while(n>0){
        v[i]=n%2;
        n/=2;
        i++;
    }
    return v;       // this represents the binary form in reverse manner
}
 
int convertdecimal(vector<int> v){
    int ans=0;
    for(int i=0; i<64; i++){
        ans+=v[i]*pow(2,i);
    }
    return ans;
}

However, this segment is absent in submission 331828373. I believe this indicates that he copied my code.

  1. The similarity in our codes might have occurred because someone viewed my solution after locking the problem and show the code to cybercondor to get paid.

Therefore, I believe I should not be deemed guilty of cheating. Could you please consider revoking the penalty?

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится -11 Проголосовать: не нравится

Dear CF admin, "Your solution 331781967 for the problem 2130C significantly coincides with solutions andy_dahiya/331781967, hacker1909_2/331851332. Such a coincidence is a clear rules violation." I have been flagged by the plagiarism checker for my code matching with some stranger. The code accused of being copied is this->https://codeforces.me/contest/2130/submission/331781967. It is the solution for the Div2 C, it was standard DSU implementation and it was auto completed by my Co-pilot which is allowed by the Codeforces AI policy (https://codeforces.me/blog/entry/133941). There was almost nothing that you can write differently in this code. This matching is purely co-incidental and completely out of my knowledge. Moreover, the other person's submission is about 2 hours later indicating that my code has no relation with his. Thus, I request you to not take any action against my account and withdraw the skipped judgment.

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    So you tell me this 331781967 and this 331851332 look almost identical (and similar to this AI/leak 331770349) just because nothing could be done differently (it obviously could 331749239)?

    More than that I see your D solutions differs in weird places, as if you rewrote main() from scratch.

    • »
      »
      »
      15 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      My C solution (331781967) is pure DSU boilerplate—there’s very little you can change—autocompleted by Copilot under your AI policy. I submitted it nearly two hours before the flagged code, so any similarity is coincidental. If you’re now questioning my D solution, please also review my E1 (331840111); you’ll see it’s entirely genuine.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится -12 Проголосовать: не нравится

Dear Codeforces Administrators,

I am writing to respectfully appeal the plagiarism flag on my submission for problem 2130C. I want to assure you that I completed this contest independently and did not share my code with any other person or consult any other participant's solution during or after the contest.

My solution is based on a standard Disjoint Set Union (DSU) data structure with path compression, which is a very common approach for this type of problem. The implementation of fundamental algorithms like DSU is often highly standardized across various educational resources and competitive programming templates. I believe any similarity detected in my code is purely coincidental and arises from the standard, boilerplate nature of the DSU implementation itself, rather than any form of academic dishonesty.

I kindly request that you review my submission again in light of this explanation.

Thank you for your time and for maintaining the integrity of this platform.

Sincerely,

varad17

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Woow!

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Great contest. Love interactive problems!

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I believe there is a missing test case in Problem 2130B - Pathless – Sum on the Subtree, which leads to incorrect solutions being accepted. Consider the following input:

5 9 0 2 2 2 1 This input represents a tree with 5 nodes and a total required sum of 9. The array specifies the desired subtree sums for each node. In this case, the configuration is already valid, and the correct output should be:

0 2 2 2 1 However, submission 342216799 incorrectly returns -1 for this input, yet it was accepted by the system. This suggests that the test cases do not cover such scenarios where the input is already a valid configuration, but the solution fails to recognize it.