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

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

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
  • Проголосовать: нравится
  • +405
  • Проголосовать: не нравится

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

As participant, Hope everyone positive Delta

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

expert now?

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

Doesn't this clash with CodeChef Starter contest?

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

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

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

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

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

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 месяцев назад, скрыть # |
 
Проголосовать: нравится -43 Проголосовать: не нравится

easy one

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

As an author, I was told to farm contribution

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

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

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

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 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

First wednesday usual time rated contest in years?

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

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

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

    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 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      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 месяцев назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        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 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      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 месяцев назад, скрыть # |
 
Проголосовать: нравится +43 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится -27 Проголосовать: не нравится

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

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

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

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

Hope I will reach pupil in first time.

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

All the best to everyone

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

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

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

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 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится -8 Проголосовать: не нравится

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

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

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 месяцев назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Hoping for fun problems and reaching specialist :)

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

anpaio is it hard__?(yes or no)

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

romania number one in coding

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

hard contest

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

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 месяцев назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

do we need fenwick tree to solve D2?

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

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 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    How C?

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

      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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

A question cooked watermelons today

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

Bro why couldn't I complete A holy hell

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

WA pretest 6 in D1 (╥_╥)

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

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

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

How to do C?

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

deleted

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

How to Approach Problem C ?

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

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

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

Screencast with commentary

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

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

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

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

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 месяцев назад, скрыть # |
 
Проголосовать: нравится -7 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится +19 Проголосовать: не нравится
My video editorial for E
»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve D1 & D2?

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

    for D1 find number of subsequences with lds<=2

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

    arent you a tester?

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

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

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

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

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

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

    Spoiler

    here is my submission: 339111975

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

D is literally this if we can identify it

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

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 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +8 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    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 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      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 месяцев назад, скрыть # ^ |
         
        Проголосовать: нравится +1 Проголосовать: не нравится

        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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

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

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

C >> D1

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

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

The pattern:

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

Plz give solution of A I am a absolute beginner

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

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

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

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

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

Loved this round, I'm an Expert again!

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

C was great

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

It was great

»
8 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
#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 месяцев назад, скрыть # |
Rev. 4  
Проголосовать: нравится -12 Проголосовать: не нравится

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 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится -11 Проголосовать: не нравится

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 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

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 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится -12 Проголосовать: не нравится

`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 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяцев назад, скрыть # |
Rev. 123  
Проголосовать: нравится 0 Проголосовать: не нравится

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