awoo's blog

By awoo, history, 18 months ago, translation, In English

Neapolis University Pafos

Hello Codeforces!

The series of Educational Rounds continues thanks to the support of the Neapolis University Pafos.

On Mar/17/2025 17:35 (Moscow time) Educational Codeforces Round 176 (Rated for Div. 2) will start.

This round will be rated for the participants with rating lower than 2100. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest, you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 6 or 7 problems and 2 hours to solve them.

The problems were invented and prepared by Adilbek adedalic Dalabaev, Ivan BledDest Androsov, Maksim Neon Mescheryakov, Alex fcspartakm Frolov and me. Also, huge thanks to Mike MikeMirzayanov Mirzayanov for great systems Polygon and Codeforces.

Good luck to all the participants!

Our friends at Neapolis University Pafos also have a message for you:

Admission to the Computer Science and Artificial Intelligence bachelor's program at Neapolis University Pafos is open!

The JetBrains Foundation supports this bachelor's program and offers 15 fully funded scholarships for the most talented applicants. The scholarships cover tuition, accommodation, medical insurance, visa fees, and pocket money (€300 per month).

Learn more here →

First admission round:

  • Application deadline – April 23, 2025
  • Entrance test – April 27, 2025

UPD: Editorial is out

  • Vote: I like it
  • +60
  • Vote: I do not like it

| Write comment?
»
18 months ago, hide # |
 
Vote: I like it +15 Vote: I do not like it

Hope that we'll find a variety of topics in this round rather than only maths or bitmasking type problems.

»
18 months ago, hide # |
Rev. 3  
Vote: I like it +33 Vote: I do not like it

I wish we could have a

^-^

Edit : Why does it always happen when I wish for something not to?

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

lets see if -100+ is possible or not

»
18 months ago, hide # |
 
Vote: I like it -23 Vote: I do not like it

score distribution?

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

Hope to enjoy this round without any technical issues. Because, the calendar has a less number of rated scheduled contests this month.

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

Why adamant about not keeping educational rounds on saturday sundays

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

Why this post has less up votes??

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

I really hope enjoy this round without the server acting unstable for no reason

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

bruh my alarm didn't ring

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

Yesss, finally, I will be back to CYAN today, inshaAllah! Scored 'C' just 13 minutes before the ending! It took me 3 unsuccessful submissions and a long time to realize that 'B' was that much easy!

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

    what was the approach for 3rd bro i tried but failed

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

      Bro, we need to choose a pair every time ensuring their "SUM" is at least 'N'. When this "AT LEAST" thing come to your mind, this is something "BINARY SEARCH". At the same time, you need to make it optimize that how many such index exists for the current index that if you form a pair their "SUM" will be at least 'N'. Then, when this "HOW MANY THING" come to your mind you need to sort the given array and use "PREFIX/ POSTFIX" sum array to optimize the counting approach using "BINARY SEARCH".

      One important point, if the value of an index is 'N', then make it 'N-1' before processing. Because, we need to make 'N' by taking at least 2 indices.

      Now, you can see my submission to align this approach in a better way. (I named the array preSum. It's actually postSum.)

      • »
        »
        »
        »
        18 months ago, hide # ^ |
         
        Vote: I like it -15 Vote: I do not like it
        /**
         * author: vanshgambhir
        **/
        #include<bits/stdc++.h>
        #define ll long long
        #define vi(n) vector<int> v(n);
        #define loop(i, n) for (int i = 0; i < n; ++i)
        #define all(v) v.begin(),v.end()
        using namespace std;
        void solve(){
        		ll n,m;
        		cin>>n>>m;
        		vector<ll> v(m);
        		loop(i,m) cin>>v[i];
        		sort(v.begin(),v.end());
        		vector<ll> suff(m);
        		suff[m-1]=v[m-1];
        		ll tot=0;
        		for(int i=m-2;i>=0;i--){
        			suff[i]=v[i]+suff[i+1];
        		}
        		for(int i=0;i<m;i++){
        			ll mini=v[i];
        			ll maxiIdx=lower_bound(v.begin()+i+1,v.end(),n-mini)-v.begin();
        			if(maxiIdx>=m) continue;
        			ll maxi=suff[maxiIdx];
        			ll cnt=m-maxiIdx;
        			tot+=maxi+(mini-n+1)*cnt;
        		}
        		cout<<tot*2<<endl;
        	}
        int main() {
        	ios_base::sync_with_stdio(0); 
            cin.tie(0); 
            cout.tie(0);
        	int t;
        	cin>>t;
        	while(t--){
        		solve();
        	 }
            return 0;
        }
        

        actually i tried but can't figure out what's wrong in this

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

wtf was B

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

How to solve E

P.S. C << B

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

    for each array , you can place at most 2 different values in each. suppose p,q in array a and l,r in array b; p>=q, l>=r; if p!=q and l!=r , you can place it (pow(2,n)-2)*pow... ways for each set of pqrl. you have to count combinations of p,q,r,l here observation is , p^q^l^r=0; i used digit dp here. there are some other combinations p==q, l==r it's easier to compute.

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

any hint to solve b?

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

    handle k is equal to 1 case explicitly otherwise it's just summation of maximum k+1 elements from the array

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

      omg, I'm gonna kill myself. I thought about that, but I didn't consider k = 1, and get wa

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

        did you try c?

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

          yeah. Actually C was easier than B

          • »
            »
            »
            »
            »
            »
            18 months ago, hide # ^ |
             
            Vote: I like it -10 Vote: I do not like it
            /**
             * author: vanshgambhir
            **/
            #include<bits/stdc++.h>
            #define ll long long
            #define vi(n) vector<int> v(n);
            #define loop(i, n) for (int i = 0; i < n; ++i)
            #define all(v) v.begin(),v.end()
            using namespace std;
            void solve(){
            		ll n,m;
            		cin>>n>>m;
            		vector<ll> v(m);
            		loop(i,m) cin>>v[i];
            		sort(v.begin(),v.end());
            		vector<ll> suff(m);
            		suff[m-1]=v[m-1];
            		ll tot=0;
            		for(int i=m-2;i>=0;i--){
            			suff[i]=v[i]+suff[i+1];
            		}
            		for(int i=0;i<m;i++){
            			ll mini=v[i];
            			ll maxiIdx=lower_bound(v.begin()+i+1,v.end(),n-mini)-v.begin();
            			if(maxiIdx>=m) continue;
            			ll maxi=suff[maxiIdx];
            			ll cnt=m-maxiIdx;
            			tot+=(((maxi+mini*cnt)-(n*cnt))+cnt);
            		}
            		cout<<tot*2<<endl;
            	}
            int main() {
            	ios_base::sync_with_stdio(0); 
                cin.tie(0); 
                cout.tie(0);
            	int t;
            	cin>>t;
            	while(t--){
            		solve();
            	 }
                return 0;
            }
            

            can you tell me what is wrong in this code? i am confused

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

why cant I submit solution now that contest is over

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

is there any smarter way of doing 2F without some cosmic-tier binary search/sweep line jank

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

    I think divide and conquer works.

    For each $$$i$$$, we find optimal $$$j$$$. Let $$$solve(l,r,a,b)$$$ mean that we are solving $$$l...r$$$ and their optimal $$$j$$$ are in $$$[a,b]$$$. Then, find the optimal $$$x$$$ for the index $$$mid$$$ and call $$$solve(l,mid-1,a,x)$$$ and $$$solve(mid+1,r,x,b)$$$.

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

    Actually the sweep line is not that complicated, you just have to notice that the best endpoints are $$$l,r$$$ such that $$$a[l]$$$ is the unique minimum of its prefix and $$$a[r]$$$ is the unique maximum of its suffix (in this problem it really helps visualizing the array as points in 2D).

    And now the candidates for $$$l$$$ and $$$r$$$ are decreasing sequences, because of that, for each element, the endpoints that it appears in are a range of each sequence (i.e. the 2D conditions are now easier 1D conditions).

    And then you do the sweep line of the biggest range intersection of the second sequence given that only pairs of ranges that contain me in the first sequence are alive.

    • »
      »
      »
      18 months ago, hide # ^ |
       
      Vote: I like it -11 Vote: I do not like it

      it took me like 10 minutes to come up with that but 10x longer to implement

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

        Not sure if this is the same as your solution (i don't understand how line sweep can be used here) but using the same ideas.

        Find the possible values of l (prefix minimums). And for each element i, the range of values of l for which it can appear in the sequence, lets call this range (l_i,r_i).

        Now we iterate through the possible values of r (suffix maximums) and for each value of r we find the largest subsequence. To do this we initialise an array arr to all 0s. For each element i<r and a_i<a_r we add 1 to all indices between l_i and r_i in arr, then the maximum element in arr is the answer. We can do this efficiently with a segment tree, since r is a decreasing sequence and a_r is an increasing sequence, each i will be added and removed at most once from the tree.

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

Panicforces.

WA multiple times, I'm cooked.

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

Could you please give me an explaination why problem B can be solved in $$$\mathcal O(n\log n)$$$ easily but $$$n\le 5000$$$?

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

    two pointers on 2D prefsums

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

    Misdirection

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

      is this really allowed in pB? I have just known that pA could (and should) be have smaller constraints.

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

    there are two cases

    when k=1: you will take any element, and take max of first and last if available.
    Logic: As you have can only paint in one direction, you can only take max of first or last element

    when k>1: you will just have to take sum of k+1 max elements in array!
    Logic: Fix range to minimum and maximum index of k+1 max elements

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

Is "D" Bruteforce?

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

    same question, I thought of bf but have no time to implement.

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

    Yes, try every possible subset for $$$x$$$ and $$$y$$$ which are disjoint and reduces $$$x$$$ and $$$y$$$ to the same value.

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

    It was dp, a normal knapsack dp

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

      Can you explain, please?

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

        Notice that dividing by 2^k and taking floor just means removing last k bits of the number. Making the 2 equal will mean (a<<i)==(b<<j) for some i,j. Also notice that if you apply operations using 2^i1 and 2^i2, it can be done in one operation of using 2^(i1+i2) (removing i1 bits and then i2 bits is equivalent to removing (i1+i2) bits together). Thus all you need to do for each i, either remove last i bits from a, or remove i bits from b, or just skip the current bit and mive to the next one (this is just standard knapsack).

        My solution for reference

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

why does my D solution is wrong recursive dp + bits 311139765

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

Good C and D :)

The only unpleasant part is B, the too many "Announcement" are misleading and interferin :(

And hope the samples can be stronger.

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


    #include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll a = 1000000007; int test; cin >> test; while(test--){ ll n,k; // map<ll,ll>mp; cin >> n >> k; vector<ll>vec; ll maxele = 0; ll sum = 0; for(ll i=0;i<k;i++){ ll x; cin >>x; vec.push_back(x); maxele = max(maxele,x); } vector<ll>ct(200000+1,0),pfx(200000+1,0); for(ll i=0;i<k;i++){ ct[vec[i]] += 1; } // ele greater than or equal to this val ll ways = 0; pfx[ct.size() - 1] = ct[ct.size() - 1]; for(ll i=ct.size() - 2;i >= 1;i--){ pfx[i] = pfx[i+1] + ct[i]; // mp[pfx[i]] += 1; } for(ll i=1;i<=(n/2);i++){ // cout << ways << endl; ll val1 = i; ll val2 = n - i; if(i < (n - i)){ ll x = pfx[n-i]; ll y = pfx[i]; // cout << x << " " << y << endl; ways += 2 * ((x) * (x-1)); ways += 2 * (x * (y-x)); } else{ ll x = pfx[i]; ways += (x * (x-1)); } } cout << ways << endl; } }

    why is time limit exceeding in my solution ????

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

      vector ct(200000 + 1, 0), pfx(200000 + 1, 0);

      You create two vectors, ct and pfx every time. If operations iterate over these vectors t times, the total number of operations can reach around 4e9 ((2e5 + 2e5) * 1e4), which can easily exceed the time limit.

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

Is there a reason why all of these submissions are the same for problem E? Either someone has several alts, or serious cheating is happening...

22R01A05B8 kushwahaarpit360123 vinay_m18

with several more (usually unrated or newbies).

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

    Livestream on YT and link to telegram group with solutions A-E :/

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

    sadly there exist multiple telegram groups sharing solutions to rounds, most of these cheaters just copy the code from these groups

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

    ALL leaked solution :> (src -yt)

    Leaked D solution
    Leaked C solution
    Leaked E solution
    • »
      »
      »
      18 months ago, hide # ^ |
       
      Vote: I like it +20 Vote: I do not like it

      Rajkumar_24M11MC100 this cheater has same codes, nigga is so dumb didnt even think for a second before copy pasting the code lol. also look at his prev contests he has 0/1 submissions.

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

      I saw that many of the top 200 participants are newbies, pupils, and specialists, which seems unusual to me. Then I checked some of their submissions, and guess what? Their submissions are quite similar to the ones you mentioned in this comment.

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

Problem B be like:

"Your first solution must be the sum of first $$$k+1$$$ maximum elements and you shall figure out the correct solution afterwards when you've already got a wrong submission"

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

Good contest, quite interesting problems.

  • A: decent number theory problem
  • B: the corner case was non obvious and I spent 1 WA and about 10 minutes to figure it out.
  • C: cute 2 pointers problem, when you need to move pointers in opposite directions (at first I was moving them in the same direction and couldn't find an error for a while lol)
  • D: have no idea why my 3d dp was not working. I thought I got this problem, but no. Better luck next time

Overall, not so bad of an Edu round. B was very educational lol.

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

    How to solve B problem? IDEA please

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

    D doesn't need any DP. I solved D with DFS, I try to guess the answer never greater than 100000. And it worked! :) :) :)

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

    can you tell how you solved C

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

      Think in terms of partitioning the fence of length n, if we have one partition of size p and another of (n-p) then we are interested in the number of ways to colour these two partitions using the ai we have, now we define X(x) = # (i: ai>=x), so basically we are interested in X(p)*X(n-p) but it overcounts some cases like (i,i) where some ai is >= n, n-p, so we have to remove such cases which would be equal to X(max(p, n-p)). You can count the frequency then form the X array, the further process is just implementing the above.

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

    C 2 pointer trap can be avoided with binary search. I was lucky to choose BS instead of 2 pointer (for real)

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

    there is nothing wrong with 3d dp . if you look other submissions , from msbs , why to only have equal reductions . That is underfit , u may even not be able to make things equal ofc excluding( u can make both as zeros which is not optimal alwys)

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

    BTW , you were very close .

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

      I've just fixed my dp. Now it TLs lol, so I should probably think of another approach

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

        Ohh overflow tle?

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

          Daamn, I didn't think about precalculating. In this problem, it is a must. Also, I couldn't figure the error about properly computing cost of making both numbers 0 during the contest.

          Indeed, an educational content here.

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

            if we have to make x and y equal and they are not zero when made equal , msb1 , msb2 as to go to some common msb (reductions are msb1 — msb , msb2 — msb). but when they are zero that they do not have to be some common msb like 2^(-1) or 2^(-2) . one can have msb of 2^(-1) x is 0 , other can have 2^(-2) y is 0 .

            e.g. 2 3

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

    What I thought was If k>1 you can always choose any k+1 numbers in the answer. With this observation it was clear about the corner case. But due to a typing mistake and not caring about the overflow I got two wa but it's okay since I registered unrated.

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

Top 7 all from Japan :D

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

dumbest contest ive ever participated in. gl CM :(

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

Such a bullshit B

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

    I really liked B tho

    maybe I'm picking a side here because this contest is my best one yet

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

I tried solving problem D by finding the longest common prefix in the binary representation of x and y. This helped me determine the highest power of 2^k that divides each of them, which I called d1 and d2. Then, I used a DP approach with a state dp[d1][d2][60], where I tried to form two disjoint sets contributing to the smallest cost. However, I’m getting WA on test 2. Can anyone help me figure out the issue? Thanks!

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

CornerCaseForces

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

I am so dumb I should leave CP ATP

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

ALL leaked solution :> (src -yt)

Leaked D solution
Leaked C solution
Leaked E solution
»
18 months ago, hide # |
 
Vote: I like it +48 Vote: I do not like it
»
18 months ago, hide # |
 
Vote: I like it -53 Vote: I do not like it

It's really really bad EDU, A is very bad, B > C and B's first test not a useful test. Make a good problem or don't make but give a useful test case LOL, B's test case always pass !!

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

any hint for $$$D$$$?

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

the closest to returning to blue, if I could realize x and y can shift same number in D and didn't write continue to avoid it

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

Please someone tell me how to solve c in a simple way. Please....

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

    Look at my solution. You know that you only need to pick two colors and paint the planks such that starting few planks have same color of first type, while the rest have the same color of second type. Now, fix the number of planks having the type of first color and then check for the possible number of ways to select colors for the second type to paint rest of the planks. Now, suppose that you can color i planks with color-1 and j planks with color-2. Now, it's only possible when a[color-1] >= i and a[color-2] >= j, which is the number of colors which can color at least i and at least j planks, respectively. Hence, total number of ways will be (number of colors having a[x] >= i) * (number of colors having a[x] >= j). But doing so, you're taking such indices for which color-1 and color-2 are same, so you need to subtract such cases. Just visualize it, the number of such cases will be the minimum of (number of colors having a[x] >= i, number of colors having a[x] >= j).

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

      nice solution too good. I also solved this problem after thinking so much. My approach is just visualise how we can get the answer if k == 2. then I created a general formuala to compute the answer for any k given. Here in my solution it does not depend upon value of n because if value of n will be greater than 1e6 then checking all could be a problem. but in my solution I will reduce the number of a[i] paints to n-1 if a[i] >= n because this is the thing which took me so much time to notice. Nice to see so much solution for a sinlge problem.

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

I don't seem to properly understand C. As a trivial/slow solution, I would apply the colors to the fence s.t. all of color i is on the left, and all of color j in on the right, and do this for all i and j. This only works if a[i] + a[j] >= n, and if so there should be a[i] + a[j] — n + 1 ways to do this, as seen in the sample testcases. We can express this as the following line of python:

res = sum(a + b - n + 1 for i, a in enumerate(l) for j, b in enumerate(l) if i != j and a + b >= n)

But even this slow solution fails on many testcases in test 2 by printing a too high answer, for example this one:

l = [5, 6, 3, 4, 3, 7, 7, 4]

gives the answer 210, but the actual answer from the judge is 182. Can someone help me understand where my error is?

Edit: n = 7 in the example

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

For B***

Sum of first K + 1 elements is correct but,

(what if k == 1, suppose the maximum is at any index != 0 and != n — 1 then we will always take the boundary elements of array, aka the last blue box)

:)

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

Are you guys able to see the standings

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

DPforces

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

Can someone please explain D, without magically defining DP.

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

    Think like we remove i bits from the first number and j bits from the second number, now we want the minimum cost to do so which we can get by dp, dp[i][j] = minimum cost to trim i bits from 1st, j bits from 2nd

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

      we find subproblem to solve in dp. how you found that dp[i][j] with the given definition is subproblem? also can you give me a hint to implement it?

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

        Division by power of 2, is trimming off last i/j digits, so the question to ask would be how much should I trim from both so as to make them equal, the answer to that would be let's say we trimmed off i bits from x and j bits from y, now what is the minimum cost to do so?, hence you would be forming the dp states as dp[i][j]= minimum cost to trim i bits from 1st, j bits from 2nd

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

Never felt so stupid solving B... Implemented maps, vector of pairs, custom sorts...just to be solved by k=1 explicit case.

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

Here is a different approach for C no problem https://codeforces.me/contest/2075/submission/311149194

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

I'm new here and don't know how to hack or generate test cases that can cause TLE for a given code. Can someone please explain this in detail or share any documentation where I can learn more about it?

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

E is very good problem although I can not solve during contest

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

When will the Ratings change??

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

System testing has finished already 4 hours ago. So, when will we get contest rating ?

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

[REDACTED] FULLY WRONG, T.T

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

    your greedy $$$Excess, X, Y$$$ would also fail at $$$X = 1, Y = 8$$$

    bitstring in this case would be $$$1110$$$ which is impossible to split into something that would sum up to $$$1$$$ and $$$8$$$

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

      dammit. Next time while posting some radical idea that everyone didn't think of, I'll AC everything first.

      OvO — > T.T

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

      By the way, how did you think of this test case? How do you think of such stabby cases in general?

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

        there's no real strat for it cause it's just something you get good at

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

Top 7 contestants are from Japan in a row!

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

wow!!boom!!!

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

HEY adedalic, BledDest, Neon, fcspartakm, MikeMirzayanov

I HOPE YOU SEE THIS !!!

ChatGPT is now solving E like it's nothing, and most cheaters are blindly submitting AI-generated solutions.

I CAUGHT ONE: Aslaan_Khan in previous contests. His/Her ranking was between 4K-20K, but suddenly, BOOMNEWBIE to SPECIALIST,

He/She completely SKIPPED PUPIL like some magic trick.

HOW DO I KNOW HE CHEATED?

  • Used AI: Code was too formatted and artificially structured.
  • Switched languages mid-contest (Suspicious af).
  • Compilation errors—dude didn't even bother running locally, just blindly pasted from ChatGPT.
  • Plagiarism tactic: Wrote everything in one single line from main to return just to bypass detection.

This is a serious issue. AI-generated solutions are polluting the leaderboard.

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

    Codeforces MUST NOT FORGIVE Aslaan Khan Aslaan_Khan. هذا الرجل غش بشكل فاضح—jumping from newbie to specialist overnight, skipping pupil like it’s nothing. This is حرام against real competitors who actually work hard.

    He SWITCHED LANGUAGES MID-CONTEST, had compilation errors because he NEVER ran it locally, and shoved the entire code into one line like some coward trying to dodge plagiarism checks. هل تعتقدون أننا أغبياء؟

    This is a مهزلة. BAN HIM. STRIP HIS RATING. اجعلوه عبرة لغيره. If Codeforces allows this nonsense, the whole platform will turn into a playground for cheaters.

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

      KAN, Una_Shem, geranazavr555, MikeMirzayanov Codeforces Headquarters, please listen!

      This is not just about one cheater—this (Aslaan_Khan) is about the integrity of competitive programming. Watching someone like Aslaan Khan jump from newbie to specialist overnight, skipping an entire rank,

      He switched languages mid-contest, had compilation errors (because he never ran the code locally), and even formatted everything in one line to dodge detection. This is blatant abuse, and it’s happening more and more with AI-generated solutions. If this continues, what’s the point of competing fairly anymore?

      I urge Codeforces to take a stand. Ban him. Please don’t let cheaters like Aslaan Khan ruin what this community stands for.

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

    @Aslaan_Khan Aslaan_Khan, your sudden leap from a 4K-20K rank to SPECIALIST raises major red flags. Your code was way too overly formatted and artificially structured, and switching languages mid-contest is sketchy. You didn’t even bother testing your code, just blindly pasted AI output. The one-line trick to bypass plagiarism checks? Unacceptable. This AI-cheating needs to end.

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

    Very True... such students should be banned from these platform and also the placement opportunities...

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

    I 100% CONFIRM Aslaan Khan (Aslaan_Khan) is a CHEATER! I checked his profile—his entire rating jump is FAKE (i.e in previous contest he struggle to get top 5k but now under 100), and all his solutions are AI-GENERATED GARBAGE.

    Check his submissions and EXPOSE THIS FRAUD!

    CF COMMUNITY EXPOSE THIS FRAUD(ASLAAN KHAN! CF COMMUNITY EXPOSE THIS FRAUD(ASLAAN KHAN! CF COMMUNITY EXPOSE THIS FRAUD(ASLAAN KHAN! CF COMMUNITY EXPOSE THIS FRAUD(ASLAAN KHAN! CF COMMUNITY EXPOSE THIS FRAUD(ASLAAN KHAN! CF COMMUNITY EXPOSE THIS FRAUD(ASLAAN KHAN! CF COMMUNITY EXPOSE THIS FRAUD(ASLAAN KHAN! CF COMMUNITY EXPOSE THIS FRAUD(ASLAAN KHAN!

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

    Biggest Cheater: arnabmanna

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

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

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

Fixed.

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

I hope it goes well.