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

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

Hello, Codeforces!

auiunu, NahC0el and me are glad to invite you to the last round with 10 binary bits — Codeforces Round 1023 (Div. 2), which will start on May/05/2025 17:35 (Moscow time). You will be given 6 problems and 1 subtask with 2 hours 15 minutes to solve them.

The round will be rated for participants of Division 2 with a rating lower than 2100. Division 1 participants can participate unofficially.

All problems are authored by auiunu, NahC0el and me.

We would like to thank:

The score distribution is $$$250-750-1500-2000-2750-(2250-2500)$$$.

We hope you will enjoy and have fun in the contest. Good luck!

UPD: Congratulations to the winners and first solves!

Div. 1+2:

  1. peti1234
  2. maspy
  3. Mangooste
  4. Sugar_fan
  5. risujiroh

Div. 2:

  1. _VanGogh_
  2. rainboy
  3. If_I_lose_it_all
  4. typeshit
  5. IHaveNoMouth_IMustScream

First solves:

UPD2: Editorial is out!

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

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

As a tester, Dominater069 orz.

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

As A participant I hope Enjoy.

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

hope to solve ABCD in 90 mins :)

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

What happened to the contest which was gonna take place tomorrow?

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

OMG round $$$(1111111111)_2$$$ as a tester!

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

Fun fact: The previous contest that had 250 points on A was Global Round 28, which was on December 2024

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

As a tester, I tested

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

As a tester, I loved the problems

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

250 for A and 1500 for C.

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

ok.. surprising that the first problem has a score of 250 .... what does this mean?

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

People should consider solving C earlier in this round.

Explanation: If somebody can solve A in 10 min, B in 20min, and C in 40 min; The solving order A,B,C gives (250-10)+(500-60)+(1500-420)=1760 round score. On the other hand, C,B,A gives (1500-160)+(500-120)+(250-70)=2000 round score. But, if you aren't able to solve C, this would work negatively.

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

    Don’t give them ideas bro I don’t wanna start solving from C…

  • »
    »
    19 месяцев назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +10 Проголосовать: не нравится
    • bruh the solving order A, B, C gives (250-10)+(500-60)+(1500-280) = 1900 and not 1760
    • and the order C, B, A gives (1500-160)+(500-120)+(250-70) = 1900 and not 2000
    • so for A — 10 minutes, B = 20 minutes, and C 40 minutes the ordering does not matter

    • but assuming A is super easy and you can solve A in 5 minutes, B in 20 minutes and C in 40
    • then order A, B, and C give (250-5)+(500-50)+(1500-260) = 1935
    • and order C, B, and A give (1500-160)+(500-120)+(250-7) = 1905

    in this case A, B, C ordering will be better

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

    Seems the problem of solve which first can be solved by greedy.I should first the problem with high division of score and time. (score/time)

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

    Oh your calculation seems wrong.The grades are both 1900

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

One of the tester is banned now lol

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

finally , i'll become newbie

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

With this score distribution problem A is going to be cout << a+b << endl;

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

luuia's testing hopefully means the round is GPT proof

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

Yeah I'm out of competition now

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

So Imma prepare a template for odd-even and sum of two no.s for A.:)

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

RGB contest

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

I hope the first problem is not just "print 2^10-1"

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

I hope to not get minus on A

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

I Wish to solve D; else will get cooked..

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

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

I know there will be an unordered_map solution which will get hacked, which makes rewhile happy.

I know it from past experience 287756206

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

As a tester, have fun and good luck!

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

why is hyman00 so strong?

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

As a participant, I hope a non-negative delta.

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

how many problems do i need to solve to reach pupil in this round.Also how much time should i invest

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

What a hard contest!

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

CASE_WORK_forces and WRONG_ANSWER_forces on C for me... One day I will properly test my code before submission.

I have some comments in my code but it is not AI generate I promise.

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

Is there any solution for D that don't require centroid, I don't want to implement centroid so I am very curious.

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

Does D solution use a tree structure with heap? What an interesting problem!

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

    I solved D just by iterating to find the tree diameter :D

    Can someone prove that this algorithm doesn't TLE? It runs in about 1.5 seconds.

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

      I was thinking same. but, what to do after first diameter? no, clues!

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

      If you cut diameter D at some iteration, next iteration your diameter will be at most D-1.

      Proof by contradiction — if in two iterations you cut two diameters of the same length D in a tree, then there must be an edge between them (since graph is connected), and then your first diameter is larger than D.

      If you remove D nodes at one iteration, then D-1, then D-2, ..., then the total number of nodes you remove O(D^2), and you do it in O(D) iterations. So at most you will have O(sqrt(n)) iterations, and total complexity is O(n*sqrt(n)).

      Maybe there is even better bound, let's see in editorial

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

I made an assumption that breaking the diameter away will always make tree less than half in size .. so that my solution will not become O(n^2) .. but I don't know the proof for this.

if this is wrong I guess I might get TLE in system tests.

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

I wish next time I could know more than I am cooked when I see the Time constraint is 5s for Problem D.

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

please tell me there is a simple trick to solve C .. I spent so much time ...

I was able to solve D faster ( although my D can fail system tests )

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

nice d2. solved A and C with tons of penalties :(

How to solve B?

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

In "C," there is no mention that the sum must be greater than -1e18.[updated]

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

Why does finding diameter trivial solution still pass time limit for this test???

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

I am Cooked.I wasn't able to solve neither A nor B. Urgently Need to practice

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

What is wrong in my code for B it is giving WA5

void solve(){
   int n , k;cin>>n>>k;
   vi v(n);
   int mini = 1e18 , maxi = -1e18;
   fr(i,n){
      cin>>v[i];
      mini = min(mini , v[i]);
      maxi = max(maxi , v[i]);
   }
   int tot = accumulate(v.begin() , v.end() , 0);
   sort(v.begin() , v.end());
   if( (maxi - mini) <= k){
      if(tot % 2 == 1){
         cout << "Tom\n";
      }
      else{
         cout << "Jerry\n";
      }
   }
   else if((maxi - mini) == (k+1)){
      if(v[n-2] == maxi){
         cout << "Jerry\n";
      }
      else{
         if(tot % 2 == 1){
            cout << "Tom\n";
         }
         else{
            cout << "Jerry\n";
         }
      }
   }
   else{
      cout << "Jerry\n";
   }
}
»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

My solution for D:

For the original tree, we find an optimal diameter and remove it from the tree. Afterward, the tree is split into several connected components, and we recursively solve the problem for each component. This process is somewhat similar to the centroid decomposition of a tree. However, I believe it is essentially a "center decomposition" of the tree.

How to compute the time complexity? We only need to consider the following problem: Given a tree T, define $$$f(T)$$$ as $$$max(f(comp[i])) + 1$$$, where $$$comp[i]$$$ are the connected components obtained by removing the diameter of $$$T$$$. An important observation is that removing the diameter of $$$T$$$ will inevitably delete the center of $$$T$$$, which ensures that the diameter of $$$comp[i]$$$ must be smaller than that of $$$T$$$. From this, we can deduce that $$$f(T)$$$ is $$$O(\sqrt(n))$$$ (for a tree $$$T$$$ satisfying $$$f(T) = i$$$, the diameter of $$$T$$$ must be $$$\ge i$$$).

I believe my implementation is $$$O(n \sqrt(n) log n)$$$, and fortunately, it passed. Unfortunately, I submitted it incorrectly multiple times.

AC code:318524754

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

E is very cool, I like it very much! F is cool too

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

how did you guys do c?

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

After the recent rounds Codeforces team showed that they don't care about cheaters and will not ban even super obvious ones, cheaters stopped even pretending they are not. Look at this clown's submissions: idk404, submitted multiple different codes for problem E in just few minutes, two of them are accepted. Some problems are solved in C++, some are solved in Python, but the variable names are so descriptive, surely a pro.

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

Solved A,B,C within 40 min, was not able to solve D, was thinking something similar to finding diameter, but unfortunately wasn't able to implement it.

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

is there easy technique to find lexicographically largest diameter ? I did 3 traversals to achieve it .. feels not very clean.

hoping to get some code pointers from editorial.

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

    I did it using dp on trees. I rooted the tree at node 1, and for each node v I stored dp[v] = the maximum value of the pair (length of path, other end of the path), over all paths whose highest point is v. The transitions are pretty straightforward. For the final answer I just iterated over every node and looked at two highest dp values among its children and merged those two paths.

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

      oh ok, thanks... I think I need to brush up on dp on trees

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

      Once a path is selected whose highest point is $$$v$$$. DP values for all the parents of $$$v$$$ needs to be updated. Did you update those values as well?

      The number of parents whose dp values need to be updated $$$\leq d$$$. So, total number of parents that need to be updated $$$\leq n$$$ over the number of paths in the answer.

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

        I'm not updating anything. I have just shared my approach to calculate the lexicographically maximum possible diameter in O(n). When I'm deleting a diameter I'm again taking O(n) time to update for the new subtrees.

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

why this code fails for problem $$$F1$$$ ?

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

What is the upper bound for time complexity for problem D?

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

Can some one help me what i did wrong in this submission, My Submission.

This is the submission for problem C, but I am getting out of bound error on string s, what have i missed?

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

why am i unofficial!!! I dont see myself on the common standings unless I click show unofficial. I registered as official and I think I am a trusted participant.

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

Where is the editorial?

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

Great problems, thanks

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

Writing From Hell because i died while debugging my own code and still not able to get where i am wrong:318542988

My approach:

1.Taking all segments where s[i]='1',and then finding max subarray sum of those segments, and storing max of all such maximum subarray sum of those segments say mx. If (mx ==k) then i set all a[i]=-1e18 such that s[i]='0' if (mx>k) then answer doesnt exist

  1. The later logic is finding the first i where s[i]='0' and then taking right[i+1,j]= max sum starting at i+1 such that all s[j]='1' and similarly left[i-1,j] where j<=i+1 and s[j]='1'.Also i stored the last indexes which were processed in left and right then for all j such that s[j]='0' && (j<lastLeft || j> lastRight) i made A[j]=-1e18.

Then returned the array.Please reply fast i am about to get deep fried here.

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

what could be the reason for a memory limit exceeded in general

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

Congratulations to MOAQ_150 for getting top 100 trusted participant, despite being unable to solve A by himself: 318512987

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

Strange, is something wrong with CF? Look at this user uk_024

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

Hello, I received a plagiarism warning for problem 2107A due to a match between solutions from emper0r_24 and dragon_emper0r. I would like to clarify that both accounts belong to me. I started giving contests using this(dragon_emper0r) account. But I mistakenly submitted the solution to A using the old id(emper0r_24). I did not intend to violate the rules. I apologize for the confusion and assure that it won't happen again. I’ll stick to one account from now on.

Thank you for your understanding.

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

There could have been two variants of the problem C.

Variant one : we can replace a[i] with any values till -10 ^ 18 to 10 ^ 18.

Variant two : we can replace a[i] with less than value till -10 ^ 6 to 10 ^ 6.

Does variant two make the question more difficult ?

sunkuangzheng ?

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

.

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

Dear Codeforces team,

I received a notification that my solution (ID: 318491650) for problem 2107C is similar to other submissions. I would like to clarify that I wrote my solution independently and did not share my code with anyone, nor did I copy from others.

I wrote the code locally on my personal computer using IntelliJ IDEA and did not use any online compilers, public repositories, or code-sharing platforms during the contest. I also did not discuss or share my solution with anyone.

Please let me know if there’s any further information I can provide to clarify this situation. Thank you for your time and understanding.

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

unforgettablepl congrats darling :D

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

Good luck to conqueror_of_tourist on his mission