LucaLucaM's blog

By LucaLucaM, 8 months ago, In English

Hello, Codeforces! Or, as we like to say in Romania: Poți să îmi dai link la rundă în privat să testez?

We are proud to invite you to Codeforces Round 1051 (Div. 2), which will be held on Sep/17/2025 17:35 (Moscow time).

The round will be rated for participants whose rating is below 2100, but higher rated users are also welcome to participate out of competition. You will be given 6-7 problems, one of which will be divided into a subtask, and 2 hours to solve them.

The problems were authored by anpaio, tvladm, MateiKing80 and by yours truly.

We would like to thank:

Score distribution: $$$500 - 1000 - 1500 - (1750 + 1000) - 2500 - 3000$$$

Good luck & have fun!

UPD: Editorial is published: https://mirror.codeforces.com/blog/entry/146526

UPD2:

Congratulations to all the winners!!!

Div. 2

  1. 72txdy
  2. Terrorb1ade
  3. bsmaN
  4. guaidaokakaxi
  5. FooFighter

Div. 1

  1. ksun48
  2. StarSilk
  3. abc864197532
  4. maspy
  5. kotatsugame
  • Vote: I like it
  • +405
  • Vote: I do not like it

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

As participant, Hope everyone positive Delta

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

expert now?

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

Doesn't this clash with CodeChef Starter contest?

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

As a tester, I tested one more round (other than this) that is in the current contest list.

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

As a tester, it's my first time testing!

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

As a tester, I did NOT commit several warcrimes in the former Yugoslavia. I think the contest is really fun and the problems are really well-made.

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

easy one

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

As an author, I was told to farm contribution

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

As a tester, the problems were so nice, I had to solve them twice

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

after getting negative delta in previous rounds, I am here with hope of getting good performance and getting back to expert.

best wishes to all.

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

First wednesday usual time rated contest in years?

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

As a participant, I hope there aren't any math problem

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

    Bruh, if you have a pen, or pencil, and a paper list, then you can solve math, i know that TOOOOOO hard to get pen and paper, but if you want to get + rating and be Pupil like me, you should learn. And, the school giving you a "base" in math, so that not like "EZ!!!!!", but not hard like two-dimensional DP.

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

      This is just not my strength. I struggle everytime a math pb append, but I can solve easily more complex DP problems (btw, I was pupil, It's just a div2 full of maths pb that downgraded me)

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

        To be fair, you have 30 problems solved total. You should probably try to practice math problems between context if you hate them so much, then you will get used to them (especially since, for pupil, you don't really need to solve ABC, just AB)

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

      Yes exactly bro! If you have learnt it and know the basic implementation then math based questions seem easy, I can even do a few 2DDP Questions but when it comes to Binary Search I will quietly sit in a corner and cry like a child.

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

omg Romania mentioned!

Drum bun, drum bun, toba bate, drum bun, bravi români, ura! Cu sacul legat în spate, cu armele-n mâini, ura!

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

As a participant I hope Real Madrid wins UCL this year Hala Madrid!

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

"Can you give me the link to the round privately so I can test it?"

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

Hope I will reach pupil in first time.

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

All the best to everyone

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

It’s really tough when Codeforces and CodeChef schedule contests at the same time. Can’t participate in both properly

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

Still looking for a contest without __baozii__. He's a great tester, yes but damn I don't think anyone has tested this many rounds in a row.

By the way is Orzify an account created SPECIFICALLY for this post?

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

As a tester, I'm totally sure that participating in the contest is better than playing FACEIT

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

Can someone help me with dp problems, what would be the best resources to learn from and any specific problemset to practice from. Thanku

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

Hoping for fun problems and reaching specialist :)

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

anpaio is it hard__?(yes or no)

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

romania number one in coding

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

hard contest

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

Two things:

1) How so many submissions on C man wtff

2) How so many submissions on D1 man wtff

EDIT: WTF MY RANK DROPPED BY 600 IN LAST 7 MINUTES?????!!!!(2816 -> 3400)

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

Problem $$$D$$$ is a beautiful problem but it cost me a headache and a half to get the DP transitions right.

Good problems and good contest, thanks for the round LucaLucaM anpaio tvladm MateiKing80 and all testers.

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

do we need fenwick tree to solve D2?

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

    what was the idea for Di got we need to avoid subsequences with lds>=3.

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

      yes, any subsequence with ids >= 3 is illegal.

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

        and thats all? all the subsequnes avoiding it is good or any more condition

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

          yes, I wrote a O((2 ^ n) * (n ^ 3)) brutal force to check it and it's correct hahaha.

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

          It's iff. Consider a graph on n vertices and an edge between i and j iff it is an inversion in the array. You can even be brave and direct the edge i->j if i < j and vice verse.

          Observe first that the graph is transitive (if u->v is an edge and v->w is an edge then u->w is an edge). Since this creates a conflict, 321s are not allowed.

          Hence 321 => inversion graph is not 2-colorable. Now suppose there are no 321s then clearly there are no larger odd-length path skips either. (Since any odd length path skip has a 321 by transitivity) so the graph IS 2-colorable in this case.

          Your sequence is good iff it has no 321 subsequence.

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

      My idea was to DP the number of subsequences with LDS 1 and 2.

      Sadly, I ran out of time :(

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

Good contest Overall , Don't know why I stucked on B for long although it was so easy after it clicked , C was simple topo qeustion , D was good literally took so much time .

Hope getting blue in next contest.

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

    How C?

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

      here , you have to arrange edges according to ( x , y) if (x>y) then v -> u otherwise u -> v .

      and then traverse according to indegree if indegree is zero then that particular node doesn't have to take tension of any node so assign maxm remaing val to this position .

      1->2 -> 3 | | 4 5
      here 3,4,5 have indegree 0 so we can put any value at this positions according to their parent and (x,y) . decrese indegree at also after processing nodes . finally you will have your ans . // this is text

      //this is code
      void solve() {
          ll n;
          cin>>n;
          vector<vi> graph(n+1);
          vector<int> in(n+1, 0);
          for (int i = 0; i < n-1; i++) {
              int u, v, x, y;
              cin >>u>>v>>x>>y;
              if (x >= y) {
                  graph[u].push_back(v);
                  in[v]++;
              } else {
                  graph[v].push_back(u);
                  in[u]++;
              }
          }
          
          queue<int> q;
          for (int i = 1; i <= n; i++) {
              if (in[i] == 0) {
                  q.push(i);
              }
          }
          
          vector<int> res(n+1);
          int current = n;
          while (!q.empty()) {
              int u = q.front();
              q.pop();
              res[u] = current;
              current--;
              for (int v : graph[u]) {
                  in[v]--;
                  if (in[v] == 0) {
                      q.push(v);
                  }
              }
          }
          
          for (int i = 1; i <= n; i++) {
              cout<<res[i]<< " ";
          }
          cout << endl;
      }
      
»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

A question cooked watermelons today

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

Bro why couldn't I complete A holy hell

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

WA pretest 6 in D1 (╥_╥)

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

couldn't even solve problem A, submitted 6 wrong submissions, all failed on pretest 2.

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

How to do C?

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

    Think of topological sorting. Try to create a directed graph with the corresponding x and y values for each edge.

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

    Notice that it is always better to take the largest one from x or y. In lieu of this,

    Construction 1 : If i < j, then we add a directed edge from i -> j if the corresponding x is equal or higher else we add a directed edge j -> i;

    Now, notice that if we perform a topological sort, and always assign the node with indegree = 0, the maximum number(multiple indegree = 0 can be assigned in any order), then we obtain the optimal sum. This is supplemented by the fact that the resulting directed graph must be directed acyclic, while simultaneously always achieving our above stated fact.

    Since it always exists and achieves our fact through construction, we are done.

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

    For each edge $$$(u,v,x,y)$$$:

    • If $$$x \gt y$$$, then to maximize we need $$$p_u \gt p_v$$$, so add edge $$$v \to u$$$.
    • Otherwise, we need $$$p_u \lt p_v$$$, so add edge $$$u \to v$$$.

    Since the original graph is a tree (no cycles), these constraints form a DAG.
    We can then do a topological sort and assign values $$$1 \dots n$$$ in topo order.

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

deleted

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

How to Approach Problem C ?

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

    Use the idea of topological sorting. The core idea is : the graph is undirected and it's a tree, hence acyclic. So, u can sort it topologically in a way that gives the maximum answer.

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

    so 1st idea is you can always choose max number from the pair ..

    so you can create a directed graph from the tree.. edge direction is decided by which number from the pair you choose

    now toposort order of that graph gives you the answer, just assign 1 to n in order of topo sort.

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

At this rate I should stop giving contests and just study until I can solve C

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

    Same man, I am struggling with C in every contest, don't know how there are so many submissions for C, its so demotivating...

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

Screencast with commentary

D1+D2 = 2750, E = 2500, F = 3000 is an insane scoring distribution. E is amazing though.

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

No way 6k ppl know topological sort. I haven't even heard of it before this round. GPTforces man

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

    Damn, it was topo sort?

    Also, you DP looks like a a jumping goat if you dont focus.

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

      Another comment said topo sort, idk fs cus I didn't get it My dp for D was bad, but I don't get D anyways

      Did u do C without topo? the 6k would make more sense then

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

        I couldn't solve C. So don't know, I was conjuring a DP solution for C. Failed miserably after 40-50 min and gave up.

        I was talking about your profile picture looking like a goat not question D.

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

          Oh yea when it's small it looks like a goat, I see a bunny though

          It's my cat, but it uploaded upside down for some reason and i'm not bothered to fix it

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

    You can solve it without topological sort, if you do an "inorder traversal" on the tree by visiting all of the children with lower value than the current node, then the node itself, then all of the children with higher value than the node. Then the nodes are ordered from 'smallest' to 'largest'. Still surprised that 6k people solved the problem, I found it pretty hard.

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

I really loved today’s contest! It wasnt too easy or too difficult. Also, it’s my first time solving Problem C in a Div 2 contest! :D :p

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

Very unlucky round for me. But the problems are good.

  • A: Neat observation. But I think that my impl is too cumbersome
  • B: The first idea is greedy. I wasn't sure so I tried to prove it and I thought that I proved. Then I had a very stupid typo which made me spend a lot of time to find and question my proof too.
  • C: Great problem. I relatively quickly figured the idea, but then stumbled upon implementation. I'm glad that I found some approach in the end.
  • D: I think that I overcomplicated the problem, but I'm not sure. After a lot of time I figured that we need to delete triangles, but I couldn't implement it.

The round was good overall. I was curious what it would be given such a good Romania performance at IOI.

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

    can you please share neat observation for A, I struggled with it a bit... ( actually I didn't read input was a permutation, then I was able to do something based on maximum in each step )

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

      I kinda just counted the number of peaks, if you have more than 1 postive peak, you cant transform. And if you have even 1 negative peak, you cant transform. I just check for both these conditions.

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

        oh cool ... thanks for sharing this observation.

        not sure why I am struggling with div2A lately :(

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

    Simpler solution for D.

    Spoiler
»
8 months ago, hide # |
 
Vote: I like it +19 Vote: I do not like it
My video editorial for E
»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve D1 & D2?

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

    for D1 find number of subsequences with lds<=2

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

      Yeah, okay. So I found the number of subsequences with LDS = 1; But, how do I find the number of subsequences that have LDS = 2?

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

      ok thanks

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

    arent you a tester?

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

      yes, but i didn't really looked through chats about solution :)

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

    here is my idea for D2(I finished my code 1 minute after the contest). here is my submission: 339160589

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

do you need to construct the tree for C to get $$$O(n\log n)$$$?

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

    It can be done in $$$O(n)$$$ with by constructing the tree.

    Spoiler

    here is my submission: 339111975

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

D is literally this if we can identify it

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

Can anybody help me debug my code for B. It failes in pretest 2. I used greedy solution to sort cost array in descending order and voucher array in ascending order. Than I pick the smallest voucher and jump to the smallest element with the cost in the group.

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

    You need long long for ans.

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

      oh no I have doen #define int long long so all my ints are long long

      • »
        »
        »
        »
        8 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it
        int i = 0, j = 0;
        while(i < k && b[i]==1)
        {
            ans -= a[j];
            i++;
            j++;
        }
        

        This may be wrong when $$$n \lt k$$$.

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

          But k has a constraint that 1<=k<=n so that won't be a problem

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

            Wait. Where did you find that constraint.

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

              Oh no my bad. There was no such constraint. I confused the other constraint for b[i] with this one.

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

              sigh...I come up with logic of an answer quite nicely but when I go to code it why do I f*ck up so much? Should I do implementation practice.

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

                Implementation is important. To gain rating, you need to code correctly and fast. But I'm not sure if some specialized training on implementation is needed, there are rarely problems with heavy implementation on Codeforces. Maybe the best way to avoid making mistake is to make them, and be careful when facing similar situation next time.

                Between, your solution for B will be correct if you change this line.

                while(i<k && j<n)
                {
                	if(j+b[i]<n)
                	{
                		ans -= a[j+b[i]];
                		j = j+b[i]; // should be j = j + b[i] + 1
                		i++;
                	}
                	else break;
                }
                
»
8 months ago, hide # |
Rev. 2  
Vote: I like it +8 Vote: I do not like it

Is there any way to solve D2 with a standard segment tree implementation? I had to copy-paste the fenwick tree implementation from cp-algorithms with 20 minutes left on the contest, because I couldn't find any other way to avoid the TLE.

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

For $$$C$$$, I just guessed that it's always possible to take $$$max(x, y)$$$ for every edge and did $$$BFS$$$ from leaf nodes and did some casework on $$$u, v, x, y$$$ and assigned values greedily and it passed lol. I have no idea what topological sort is :)

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

noooo !! didn't see C is topological sort..so tried to code it myself and made 1 WA ..

also D looks like nice DP which I couldn't figure out. I think we need to find count of subsequences with longest decreasing sequence having length < 3

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

    you don't need to topo-sort. You can kind of start on any node , but just reverse the constraint on edges if your going in opposite direction

    if u -> v then x,y

    if v -> u then y,x

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

      i think I understand what u saying, because it is a tree..

      shouldn't we start with a node which as 0 in-degree ?

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

        This works because its a tree.

        Greedy proof: You can always assign some value to a node to take best of (x or y) of an edge. This decision will not affect other nodes ( because its a tree ).

        If lets say i give some value to a node 1 . I can always give values lesser or greater to my neighbors to get the best from these edges .

        This works because what ever value I give to my neighbor wont affect each other (might not be the case for a graph)

        For the start assume you can give any value to a node , later normalize it to bring it under the permutation constraint

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

is there a simple $$$O(n ^ 2)$$$ solution for D2? I had to use fenwick trees for half of my transitions from D1, and it was painful to implement

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

Enjoyed solving A,B,C, but I feel super sad knowing I’m going to get a huge negative delta -_-

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

    if you solved 3 problems why negative delta..were you very slow in submission ?

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

      Only C was slow, but I’m using an extension called CorrectIt, and last time it showed –56

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

        oh ok ... best wishes .. it seems I might also get small negative delta :( :(

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

          Thanks bro, good wishes for you too. The main reason C was slow is that I solved it in a really weird way, so I spent a lot of time while debugging

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

C >> D1

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

The pattern a_i > a_j > a_k is not real. It can't hurt you.

The pattern:

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

Plz give solution of A I am a absolute beginner

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

Tight constraints for D2. In contest Segment tree solution gets a TLE but passes by Fenwick tree (used gpt generated conversion) code

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

E is the easiest problem I have ever seen for a while... However I don't know why my rank always decreases :(

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

Loved this round, I'm an Expert again!

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

C was great

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

It was great

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;

int dp[301][302][302];
signed main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int t;
	cin >> t;
	while(t--) {
		int n;
		cin >> n;
		vector<int> arr(n);
		for(int i=0;i<n;i++) cin >> arr[n-1-i];
	
		// Now we will find those subseq in which LIS length is <=2
		for(int i=301;i>=0;i--) {
			for(int j=301;j>=0;j--){
				dp[n][i][j] = 1;
			}
		}
		for(int i=n-1;i>=0;i--) {
			for(int j=1;j<=301;j++) {
				for(int k=1;k<=301;k++) {
					dp[i][j][k] = dp[i+1][j][k];
					if(j >= arr[i]) dp[i][j][k] = (dp[i+1][arr[i]][k] + dp[i][j][k])%mod;
					else if(k >= arr[i]) dp[i][j][k] = (dp[i+1][j][arr[i]] + dp[i][j][k])%mod;
				}
			}
		}

		cout << dp[0][301][301] << "\n";
	}
    return 0;
}

Can anyone help optimise my code? Like I thought D1 differently. I reversed the array and then I will find subsequences with LIS length <= 2. For that I have just maintained the first 2 elements of the array (the one we maintain while finding LIS length in nlogn time). 
The major difference with the official solution is that my solution requires updating a matrix rather than a row due to which I am unable to apply segment tree optimisation directly. If there's any way to optimise this kindly tell.


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

Dear Codeforces administrators,

Regarding my solution 339112959 for problem 2143C: I would like to clarify that I independently implemented a standard topological sort (Kahn’s algorithm) for this problem.

The similarity with other submission arises because: – The algorithm is a well-known, standard approach for such graph problems. — All input variable naming is taken from question itself and from standard algorithm (n, u, v, x, y, din, g) – The graph construction (by comparing x/y values and assigning edge directions) follows directly from the problem statement, so many solutions naturally look alike.

I did not share my code with anyone, nor did I use any public online compilers or platforms that could have leaked my solution.

I kindly request you to reconsider this flag, as the resemblance is a consequence of the common algorithmic approach and not due to intentional code sharing or plagiarism.

Thank you for your time and understanding.

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

Regarding Similarity Allegation on Submission submission:339093124

Hello everyone,

I recently received a plagiarism warning regarding my submission 339093124 for problem 2143A in Codeforces Round 1051 (Div. 2). It was flagged as being very similar to another submission by [user:Anurag_2314] submission ID 339128344). I would like to clarify my side and provide some context.

1. About the Other Submission It was mentioned that the code by Anurag_2312 339128344 looks very similar to mine. I would like to point out that: That user first submitted a different version of the solution, which was accepted. Later, they submitted another version whose implementation looks closer to mine. The resemblance is a result of the straightforward nature of the problem, not copying.

2. No Intentional Sharing or Copying I want to make it clear that: I did not share my solution with anyone. I did not copy code from anyone. I have never uploaded my contest solutions to public platforms like Ideone (with public access) or GitHub during/after contests. Any similarity is due to the simplicity of the problem and the limited number of natural ways to implement it, not due to collusion or leakage.

Final Note I respect Codeforces rules and contest integrity, and I am always careful not to engage in any form of unfair play. Given the above explanation, I kindly request the moderators to reconsider this plagiarism strike and remove it from my account, as the similarity arose only from the straightforward nature of the problem’s implementation.

I kindly request you to reconsider this flag, as the resemblance is a consequence of the common approach and not due to intentional code sharing or plagiarism.

Thank you for your understanding.

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

Dear Codeforces administrators,

Regarding my solution 339126451 for problem 2143C: I would like to clarify that I independently implemented a standard topological sort (Kahn’s algorithm) for this problem.

The similarity with submission [339149501] arises because: – The algorithm is a well-known, standard approach for such graph problems. - All input variable naming is taken from question itself and from standard algorithm (n, u, v, x, y, p, adj) – The graph construction (by comparing x/y values and assigning edge directions) follows directly from the problem statement, so many solutions naturally look alike.

I did not share my code with anyone, nor did I use any public online compilers or platforms that could have leaked my solution.

I kindly request you to reconsider this flag, as the resemblance is a consequence of the common algorithmic approach and not due to intentional code sharing or plagiarism.

Thank you for your time and understanding.

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

`2143A - All Lengths Subtraction it is purely coincidence that mine and someone else's solution got matched. I haven't used any compilers like ideone(where code is publicly available) too and also I didn't even know the other person with whom the solution got matched. also I have submitted the solution earlier. This is a mere coincidence, I understand that it is not ethical to provide code for someone else or use someone else's code. Please reconsider the flag. Thank you.

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

Hello,

My submission 339093124 for Problem 2143A in Codeforces Round 1051 (Div. 2) was flagged for similarity with [user:Anurag_2312]’s submission 339128344. I would like to clarify:

No Sharing or Copying – I have never shared my code with anyone, nor copied from any external source. I also do not use public compilers/platforms (like Ideone) where my solutions could be exposed.

Order of Submissions – I submitted my solution earlier. The other user’s later submission resembled mine only because the problem is straightforward and naturally leads to similar implementations.

Pure Coincidence – Any similarity is coincidental and due to the limited number of ways to solve the problem, not plagiarism.

I respect Codeforces rules and contest integrity, and I kindly request reconsideration of this strike.

Thank you for your understanding.

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

Hi there, I want you all to see the following 3 submissions which I found on Question C solution of many accounts.

339121255 339118543 339119152

I saw complete similarities in all these codes so I am letting you know if you also think there might been some kind of plag or any thing similar kindly take appropriate actions