Bahamin's blog

By Bahamin, history, 9 months ago, In English

Hope you enjoyed the problems!

2127A - Mix Mex Max
Idea: Bahamin
Preparation: Hamed_Ghaffari

Hints
Solution
Code

2127B - Hamiiid, Haaamid... Hamid?
Idea: _R00T and Error_Yuan
Preparation: _R00T and Hamed_Ghaffari

Hints
Solution
Code

2127C - Trip Shopping
Idea: Bahamin
Preparation: Bahamin and _R00T

Hints
Solution
Code
Bonus

2127D - Root was Built by Love, Broken by Destiny
Idea: _R00T and Bahamin
Preparation: _R00T and Hamed_Ghaffari

Hints
Solution
Code

2127E - Ancient Tree
Idea: Bahamin
Preparation: Bahamin and Hamed_Ghaffari

Hints
Solution
Code

2127F - Hamed and AghaBalaSar
Idea: Hamed_Ghaffari and _R00T
Preparation: Hamed_Ghaffari

Hints
Solution
Code

2127G1 - Inter Active (Easy Version)
Idea: Ali_BBN
Preparation: Hamed_Ghaffari and Ali_BBN

Hints
Solution
Code
Bonus

2127G2 - Inter Active (Hard Version)
Solution & Analysis: LMydd0225 and Error_Yuan
Preparation: _R00T and Hamed_Ghaffari

This version used an almost completely different approach from G1. Here's the step-by-step analysis:

Analysis (Steps & Hints)
Code

2127H - 23 Rises Again
Idea: sweetweasel and eren__
Preparation: Hamed_Ghaffari and _R00T

Hints
Solution
Code
Apology
  • Vote: I like it
  • +243
  • Vote: I do not like it

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

Auto comment: topic has been updated by Bahamin (previous revision, new revision, compare).

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

Fast editorial!

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

why my standing/leaderboard still broken, any ideas?

Edit: I no longer have this problem

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

Thank you for preparing such a clear and detailed editorial. It was truly insightful

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

although I attempted only 4 problems I enjoyed the contest.. thanks for fast editorial

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

nice problems and nice explaination thank you

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

GPT able to solve H....highly unexpected....

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

can anyone clarify where i have done wrong for 2127B - Hamiiid, Haaamid... Hamid?_

// this is code
void inc(int pos, int d) {
    for (; pos < n; pos |= pos + 1)
        f[pos] += d;
}

code:

import java.util.*;

public class Main { public static int solve(Scanner sc) { int length = sc.nextInt(); int position = sc.nextInt() — 1; String path = sc.next();

int leftWalls = 0, leftEmpty = 0;
    int rightWalls = 0, rightEmpty = 0;

    for (int i = 0; i < position; i++) {
        if (path.charAt(i) == '#') leftWalls++;
        else leftEmpty++;
    }

    for (int i = position + 1; i < length; i++) {
        if (path.charAt(i) == '#') rightWalls++;
        else rightEmpty++;
    }

    if (leftWalls == 0 || rightWalls == 0) {
        return 1;
    }

    int fromLeft = leftWalls + Math.min(rightWalls, leftEmpty);
    int fromRight = rightWalls + Math.min(leftWalls, rightEmpty);

    return Math.min(fromLeft, fromRight) + 1;
}

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int t = sc.nextInt();

    while (t-- > 0) {
        System.out.println(solve(sc));
    }
}

}

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

    Maybe the best option to escape is choose a direction and don't change it.

    Try this test case:

    testcase

    The answer should be 2 because Mani can choose the 3rd grid and block it at first, and Hamid need to use 2 days anyhow.

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

Easy backtrack solution for H (not as easy as the random shuffle solution, but it did not require any parameter tweaking so I will take it as a win)

We will go in increasing order of vertice id, adding new edges from the current vertice to ones with larger id. Notice that if we can add an edge, it is never beneficial to not do so. That's it.

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

A, B, C and D are all high-quality! To my surprise the E need virtual tree (or DSU on tree according to the discuss of other participants). Unfortunately I mastered none of them.

Perhaps they are commonly used in advanced problems. Anyway, thanks for sharing these amazing problem and I think I need to learn them now. :D

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

For problem E, I wasn't aware of virtual tree, and I think the "other solutions" include my small-to-large solution.

We can run DFS on the tree and retrieve the set of colors from each subtree, but only the reference to the sets instead of copying it every time. Determining the color of this node is identical to the editorial's strategy. By merging all the sets into the largest set among them, the total number of insertions during merging is $$$\mathcal{O}(n\log{n})$$$ and each insertion takes $$$\mathcal{O}(\log{n})$$$. Therefore, this solution runs in $$$\mathcal{O}(n\log^2{n})$$$ time in total.

My submission: 332889063

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

    I was actually able to do the part you have mentioned. Can you please help me with the part on how to apply color to non-colored(unknown colored nodes) such a way final answer doesn't increase ? I wasn't able to do this part. :( .

    My code .
    • »
      »
      »
      9 months ago, hide # ^ |
       
      Vote: I like it +1 Vote: I do not like it

      You just need to keep these nodes uncolored, and after this phase, you can run another traversal on the tree which propagates the parent's color to its children, and color the uncolored nodes with this color.

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

        Same Thought bro

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

        damn :| . I thought about this approach as well.

        If the parent node isn't colored, then what to do ? ( I tried started propagating one of the child's color to its parent. ).

        Above approach worked until, test case that has zero colored nodes.




        0 / | \ 2 2 2 k = 2 , Now how to decide which color to give to the root node ? ( I started propagating one of the non-zero child's value to parent. Then I got stuck at below... ) 2 / | \ 0 0 0 ---- If was passing value form parent to child, second test case fails, and vice versa first one fails. May be I should have done both ...
        • »
          »
          »
          »
          »
          9 months ago, hide # ^ |
          Rev. 2  
          Vote: I like it 0 Vote: I do not like it

          If you followed these "small-to-large" steps, then the only uncolored nodes can only be the root of an uncolored subtree, in which case you can just start the traversal from the root and all nodes will be naturally colored with the parent's color. If the whole tree is uncolored, you can just color the whole tree with color $$$1$$$ and then the cost is $$$0$$$.

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

          In the first case, you can set the root's color as $$$2$$$ during the "small-to-large" phase (children to parent propagation). In the second case, you leave the uncolored nodes in this phase, and during the second traversal you propagate the root's color ($$$2$$$) to its children (parent to children propagation).

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

    Hi, I just solved this problem with the same approach, but I'm concerned about one thing. I store the set of colors for every node in the tree, and don't delete them after I use them. Still, my code only takes around 80MB of memory even though I think its memory complexity is O(n^2). Could you explain why this is the case?

    My code: 339460078

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

god DAMN.

Light speed editorial

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

solution outline for E without mentioning virtual tree:

iterate nodes in dfs order (i.e. pre-order traversal). i claim that we can assign colors to nodes where $$$c_u=0$$$, such that we don't increase the number of "doomed" vertices (as mentioned in the editorial's hints).

let the "color set" of $$$u$$$ be the set of pre-assigned colors in subtree $$$u$$$. Note that we can obtain this information via small-to-large merging.

For each node $$$u$$$, consider the number of colors that appear in multiple colors sets. If there is exactly 1 such color, let it be $$$s_u$$$, otherwise let $$$s_u=-1$$$.

  1. for nodes where $$$s_u\neq -1$$$ and $$$c_u=0$$$, we want to set $$$c_u:=s_u$$$.

  2. for nodes where $$$s_u=-1$$$ and $$$c_u=0$$$, we set $$$c_u:=c_{fa_u}$$$ where $$$fa_u$$$ is parent of $$$u$$$ or $$$c_u:=1$$$ if $$$u=1$$$.

Notice that in the first case, we don't add doomed vertices since $$$u$$$ doesn't become doomed and none of $$$u$$$'s ancestors can become doomed (they must have been doomed already due to occurences of $$$s_u$$$ in $$$u$$$'s subtree).

In the second case:

a) If all of u's children's color sets are disjoint, then $$$u$$$ doesn't become doomed, and none of $$$u$$$ ancestors can become doomed: $$$fa_u$$$ can't become doomed since $$$c_u=c_{fa_u}$$$, and higher ancestors can't become doomed (otherwise $$$fa_u$$$ would've already made them doomed).

b) If there are >=2 colors that appear in u's children's color sets, then u was doomed already. Then by the same argument in a), we can show that none of u's ancestors become doomed.

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

Cant understand why i'm getting WA on test 5 in problem D. Probably missing some case where i have to multiply 0. Can someone help? 332893206 Update: NVM got it.

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

A better solution for H:

Take out a single biconnected component and it's easy to see that any node in this component can have a maximum degree of $$$3$$$. Otherwise any $$$2$$$ neighboring edges from this node can form a cycle (since the graph is biconnected), leading to at least $$$6$$$.

It's also easy to see that there are at most $$$4$$$ nodes with degree $$$=3$$$ in this component, otherwise there will be at least $$$2^3=8$$$ cycles. Since at the end we keep at most $$$2$$$ edges from any node, we can choose an unused edge and delete it from a node with degree $$$=3$$$ without changing the answer. Since we don't know yet which edge is used, we can only brute force to try all possibilities in $$$O(3^4)$$$ time.

Now we have a graph where every node has degree $$$\le 2$$$, which means every component is either a cycle or a chain, and we can do standard dp on this graph to obtain the answer. The dp can be done in $$$O(n)$$$ time if implemented carefully.

Back in the original problem, we build the block-forest of the original graph and do a tree dp on it. For every biconnected component, we do the brute force and dp above with the answers obtained in the subtrees.

The total complexity is $$$O(3^4 n)$$$ (or maybe $$$O(3^4 n^2)$$$), which is way much smaller than the author's solution. The downside is that this solution is very very hard to implement and hard to debug. I wrote ~7K and took >2h to debug it, so this solution won't pay off in the contest, unfortunately :(

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

I think for H, you should probably assume that a backtracking/heuristic solution exists, since the limits are really small to allow these sorts of solutions. At least testers should have found a better solution and buff $$$n$$$.

Some alternative solutions:

Matching (+some rant)
DP
Better DP
»
9 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

I present to you the dumbest solution for A. I noticed the pattern... but didn't realize I could just code it like that

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int mex(int a, int b, int c){
    for(int i=0; i < a + b + c + 2; ++i){
        if(i != a && i != b && i != c){
            return i;
        }
    }
}

int max(int a, int b, int c){
    return max(a,max(b,c));
}

int min(int a, int b, int c){
    return min(a,min(b,c));
}

int main()
{
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int>a(n);
        for(int i=0; i < n; ++i){
            cin >> a[i];
        }
        int num = 1;
        for(int i=0; i < n; ++i){
            if(a[i] != -1){
                num = a[i];
            }
        }
        for(int i=0; i < n; ++i){
            if(a[i] == -1){
                a[i] = num;
            }
        }
        bool ok = 0;
        for(int i=0; i < n - 2; ++i){
            if(mex(a[i],a[i + 1], a[i+2]) == max(a[i],a[i + 1], a[i+2]) - min(a[i],a[i + 1], a[i+2])){
                ok = 1;
            }else{
                ok = 0;
                cout <<"NO"<<endl;
                break;
            }
        }
        if(ok){
            cout << "YES"<<endl;
        }
    }
}

✅ AC on 332878042

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

is there a DFS based approach for D ?something where we count child with deg one and use factorial based logic after that ??

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

I like the problems, especially E. Thanks for the contest!

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

In problem C i ordered (arrA[i],arrB[i]) array by arrA[i] and look for adjacent pairs to find shorter distance. Should it work or are cases weak?

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

    It should work. I did the same. Basically, lets say a,b,c,d are the numbers that bob is gonna rearrange. He will benefit when (lets say min of these 4 is a and max is d) a and d are far away from each other but are already not paired up. So our idea works because we try to keep this a and d as close as possible and then calculate the ans.

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

      Thank you by your reply, but i couldnt understand what is gonna happen in a case like:

      (1,2) (2,50) (3,4)

      comparing by x will keep this order, but best choice would be (1,2) (3,4) instead of (1,2) (2,50)

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

        I don't exactly understand what you mean by "(1,2)(3,4) instead of (1,2)(2,50)"

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

          Supose a = [1,2,3] and b = [2,50,4]

          Index 0 -> pair (1,2) Index 1 -> pair (2,50) Index 2 -> pair (3,4)

          If we sort by x and compare adjacent pairs, we will compare (1,2) with (2,50) and (2,50) with (3,4), while the best option is (1,2) with (3,4)

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

            Do you mean to say, Alice will choose [1,2] and [3,4]?

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

              Yes, thats the optimal choice, but i cant see how it works when we choice pairs ordering by x

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

                If Alice chooses [1,2][3,4], Bob would rearrange them to make [1,4][2,3] which will increase the original answer by 2. Alice would actually choose [2,50][3,4] as no matter how Bob rearranges it, he can't increase the answer.

                I think you are confused between Alice and Bob's goals. Alice is trying to choose i and j such that the answer as a minimum increase, or possibly no increase.

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

      i got ac after reading this , i thinked for 2 hours how to find those pairs which will choose by ali and bahamin can not take more benefit from those pair , can you give me proof or something which help me to know sorting is enough like but i am not getting feel , please help me

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

        It's simple, I'm not sure if I can give you some kind of mathematical proof but the idea is if I'm Alice, I just don't want to give Bob an advantage.

        When does Bob get an advantage? When the min and max of the 4 numbers are far away from each other.

        So you can be like in this case [5,1] [10, 100], 1 and 100 are far from each other (and Bob can rearrange this to get an advantage) but when I sort based on first array, they lie adjacently.

        Okay lets extend the array now. So now rest of the values, assuming 100 is the largest in both the arrays; for first array new values we fill in should be greater than 10 (as it is sorted) but the corresponding value in the second array should be less than 100 based on our assumption.

        So no matter how you fill in, one possible way is [5,1] [10, 100] [20, 40] [30, 80]. May be [5,1][10, 100] being adjacent is an advantage for Bob. But now Alice can choose [10,100][20,40] as 20 is lying between 10 and 100.

        I just went with my intuition during the contest, maybe I was lucky. But if you take more cases and analyze, you might understand it better.

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

          yes like for each test case result is same , but the thing is you can realise this during contest that sorting and then just checking adjacent will work like for div 2 c you will not be able to realise your self this works

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

            If you think each pairing as a line segment, you will realize no matter if you considering starting points of line segment or ending points of line segment for sorting, the closest ones will appear next to each other in sorted order. This can be another way to look at it.

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

    can you help me understand why is K completely ignored in all solutions i saw for C, i mean we are doing n-1 operations and if k<n-1 and all the operationa actually take place , isn't it a violation of the constraints

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

      It is no where mentioned alice has to choose different i and j every time. So Alice will greedily keep choosing the same i and j.

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

        ohkk , got this perfectly, now i have one more doubt,

        suppose we have stored vtr as {Ai , Bi} sorted on Ai where Ai<Bi ,

        Now for the index i and i+1 , we have four values Ai , Bi , Ai+1 , Bi+1, the current minimum contribution being cur = abs(Bi-Ai) + abs(Bi+1-Ai+1), Bahamin can simply sort the four values suppose as temp[0], temp[1], temp[2], temp[3], then the max he can get is newn = (temp[3]-temp[0]) + (temp[2]-temp[1]), the extra difference being newn — cur(if newn>cur), but the editorial says newn should be abs(Bi+1-Ai) + abs(Ai+1-Bi), my doubt is we know Ai<Ai+1 but its not necessary that Bi<Ai+1 and Bi+1<Ai ,

        ideally sorting the 4 values and then taking the difference should make sense, but its WA on test2 , like getting 2 instead of 0.

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

      After first operation, alice can choose same elements for every remaining k, so bahamin will not be able to increase v

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

Thank you for the great problem and lightning fast editorial! But imo, B is a little hard for Div.2B

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

Excellent contest, problems are intreresting indeed

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

Thanks the authors for the quality of the contest! Great solutions for B and C!

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

Although I faced lots of difficulties, it really taught me something I didn't know. Thank you for the contest.

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

Problem C is very good and interesting but for me problem D much more easier than C.

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

what is "Stars and bars" in editorial of F?

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

Didn’t participate in the contest, but really enjoyed solving this problem later. The idea was elegant and the implementation was fun. Thanks to the author and testers

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

I learned a lot from problem F. I like the solution!

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

The solution of C provided is amazing. I have already made out case 1 and case 2 myself. How can we finally know using the intersection of intervals to figure out case 1 or case 2?

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

D is a very good problem

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

All of the problems were good. All of the solutions are verrry beautiful but unfortunately, H was accepted with an easy way. but in the end, it was a very, very good contest and thank you all.

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

in the first question unordered_set is better right since we don't need the order

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

In problem, the statement says,

In each day, the following events happen in order:
1. Mani selects an empty cell and builds a wall in that cell. Note that he can not build a wall in the cell which Hamid currently is at;
2. Hamid selects a direction (left or right)

Dosn't it mean Mani always starts first ?

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

The symmetry in F for determining the contributions of the subtracted elements is very nice! Unfortunately during the contest, I found the following on upper-bound integer sums, and the formula looked $$$O(n)$$$ so I thought there must've been a different thinking path. It also looked intimidating lol, but it turns out that figuring it out yourself isn't too difficult.

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

Can anyone help in Bonus of C?

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

Can someone explain the implementation part of E without the use of virtual trees? I have got the logic that

if node has value; --> cutie then skip --> else make all -1 in its subtree = this value;

if ith node has 0; --> cutie then skip --> else do nothing;

end -> make all 0 = root;

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

got a randomized solution for G2 with $$$n (\log n + 1)$$$ queries for large $$$n$$$($$$n \gt 14$$$), 333152719. Though for small $$$n$$$ I have no idea how to solve it quickly, some randomised approach gave me the same 8n, so this solution makes no more than 8n queries

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

in problem C I do not understand where the solution takes k(the number of rounds) into consideration. I understood the solution as assuming we have infinite number of rounds to reorder the arrays and add gains as we wish. can someone please explain?

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

For problem H, we found an algorithm with $$$O(2^5n)$$$ time complexity.

https://mirror.codeforces.com/contest/2127/submission/333483386

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

333522158,problem D,I don't know why it wa on text2 52nd

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

Regarding submission 332832455 — Problem C: Trip Shopping I recently received a plagiarism warning for my submission 332832455 in Problem 2127C.I did not intentionally share my code or copy from others. I would like to clarify the situation. I did not share my code with anyone, nor did I copy from any other participant. The similarity with another solution appears because: Standard Approach – This problem naturally leads to a “sort intervals + check overlap + find min gap” strategy. Common Variable Naming – My variable names (s, e, ivs) are short and generic, which is common in competitive programming due to time pressure. Many participants independently write similar-looking code in such situations. Independent Implementation – I implemented the solution entirely on my own during the contest without consulting any external sources or public IDEs. Limited Variation in Logic – The problem has a relatively straightforward optimal approach, which often results in structurally similar code even when written independently. I request that you please review my case, as the resemblance is coincidental and due to the nature of the problem and typical competitive programming practices.

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

In the editorial's solution for B, there seems to be a typo; it says:

So the answer becomes either $$$\min((x−1)+1,n−R+2)$$$ or $$$\min(L+1,n−(x+1)+1)$$$

when it should say:

So the answer becomes either $$$\min((x−1)+1,n−R+2)$$$ or $$$\min(L+1,n−\underline x +1)$$$

which is correctly stated in the final solution:

$$$\max(\min(x,n−R+2),\min(L+1,n−x+1))$$$

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

can someone pls help with checking why this is tle,

problem E,

https://mirror.codeforces.com/contest/2127/submission/336913209

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

Problem D: Why does this solution get WA at test 2 ?? I used small to large merging on trees to store the distinct colors in subtrees of all nodes. My submission: 338256378