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

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

Hello, Codeforces!

I'm glad to invite everyone to Codeforces Round 1008 (Div. 1), Codeforces Round 1008 (Div. 2), which will be held on Mar/10/2025 17:45 (Moscow time).

You will be offered $$$7$$$ problems in both divisions 1 and 2, and you will be given $$$2$$$ hours and $$$30$$$ minutes to solve them.

Both divisions contain at least one interactive problem(s). Please look up the guide if you are unfamiliar with them.

I'd like to give my utmost thanks to

I hope everyone will indulge in the tasks blissfully.

Score distribution

Division 1: $$$500-1000-1500-2250-2250-2500-3000$$$

Division 2: $$$500-750-1250-1750-2000-2750-3500$$$

Congratulations to the winners!

Division 1

  1. jiangly

  2. Ormlis

  3. Um_nik

  4. tourist

  5. ksun48

Division 2

  1. a1048576

  2. SussykinWantsNatalia

  3. DanielAnker

  4. Manasvi

  5. hungpc1577

Editorial

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

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

For the first time Div2 is unrated for me!

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

I think there is a bug in registration because everyone able to register for div1

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

I see satyam343, I wait for a sweaty binary search problem

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

As a tester, I tested.

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

why are there so many new accounts registered a couple minutes ago registering for div1? are they bots from ai companies / research groups?

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

As a tester, this contest was a div2-only round when I tested it.

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

omsincoconut Please suggest which topic I need to practice to participate in this round , if possible .

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

Am i even eligible for div 2?

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

As a tester, do not forget to turn on your computer before the round

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

As a contestant if I see a permutation construction B, I will skip :)

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

Expecting increase

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

Is the contest rated ?

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

As a tester, I can ensure that omsincoconut is not a real coconut.

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

Finally, the first rated round of this month!!!

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

I'm a Chinese senior high school student. I really want to participate in this contest, but the contest will last until 1:15 a.m. in China, while I have to go to school at 7:30 a.m. Should I sacrifice my spare time to join the competition?

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

I'm on like 3hrs of sleep but we gamble

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

Site is way too slow,nothing is loading.

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

it's getting unbearable atm

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

thank u for these soundtracks

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

Arcaea Round

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

someone just tell me how to do div2-c.

Scratched my head for more than an hour.

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

how to solve E ? what are the questions you ask ?

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

how to 1E

i got to the point where you can make a set of indices $$$i[1], i[2], ..., i[k]$$$ darker iff $$$i[u] - i[u-1]$$$ odd for all $$$u$$$ but idk how to continue from there

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

    My line of thought was the following:

    We can simulate a subarray with the following code

    long long openEven = 0, openOdd = 0, ans = 0;
    for(int i = l; i < r; i++) {
    	if(i % 2 == 0) {
    		if(a[i] >= openOdd) {
    			ans += a[i] - openOdd;
    			openEven += a[i];
    			openOdd = 0;
    		} else {
    			openOdd -= a[i];
    			openEven += a[i];
    		}
    	} else {
    		if(a[i] >= openEven) {
    			ans += a[i] - openEven;
    			openOdd += a[i];
    			openEven = 0;
    		} else {
    			openEven -= a[i];
    			openOdd += a[i];
    		}
    	}
    }
    return ans;
    

    Then I realized that this is something to do with prefix sum balance of the subarray. The problem turns into finding the maximum prefix sum — minimum prefix sum of the subarray taking b[i] = i % 2 == 0 ? a[i] : -a[i] (there's a graph interpretation for this that I've learned and seen from quite a few past problems) and now it shouldn't be that hard for you.

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

What was the second query supposed to be for Div2 D? Also, how come so many solves on F?!!

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

I knew exactly what to calculate in Div1C, but couldn't know how to calculate it efficiently :(

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

Who would have thought a scammy game ads could've been this hard of a problem?

Any hints for div2D?

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

    it was greedy , idk why i coded and it worked :)

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

    For each +X, we calculate its contribution to the total answer, which is the number of times clones of it at the end. We start with +1 to simulate the presence of two individuals at the beginning.

    We maintain two variables, L_i and R_i, to track the maximum number of duplicates we can achieve when progressing through gates i to N, where we choose either the left or right gate at the ith gate, respectively.

    If the ith gate is an addition (+), then: L_i = L_(i+1) (No clones are made, the same guys move to the next gate)

    If the ith gate is a multiplication (* X), then: L_i = L_(i+1) + (X — 1) * max(L_(i+1), R_(i+1)) (Here, X — 1 duplicates are created, which can choose between the next gates based on which will maximize the number of future clones)

    The updates for R_i are done in the same way.

    Finally, sum the contributions of all + operations to compute the total answer.

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

for 2F/1C I got some mathematical expression but couldnt simplify, so I generated F(N, K) = answer when you have K 0's, and via OEIS i realized that F(K) is a 3rd degree polynomial and just used brute + oeis to find the coefficients. How are you supposed to do it normally???

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

Couldn't optimize D. I distilled it down to its optimal to either use all extras in lane 1 or all in lane 2, Couldn't think of a greedy heuristic to use to prune down to the optimal path so ended up being 2^n TLE. I'm guessing it has to do with the fact that the multiples are either 2 or 3, but ran out of thinking time

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

    My solution was just O(n^2) greedy. It's always optimal to either send all extra to lane 1 or lane 2. There are 4 cases,

    Case 1: + x, in which case it is always optimal to send extras to lane 2.

    Case 2: x +, in which case it is always optimal to send extras to lane 1.

    Case 3: + +, in which case you just accumulate more extras.

    Case 4: x x, in which case you either send extras to the one with the larger x, or look down the line to find the first x in lane 1 or lane 2 (similar logic if they are the same).

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

      This makes sense. I think where I messed up was attempting to calculate the extras allocation too soon.

      Your solution delays the decision by carrying over the extras further down the road to always make the decision where it matters. Thanks for the explanation.

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

      Why do you just assign the "extra" towards the lane where you find greater multiple down the line or the first multiple? Wouldn't you look over all the multiples and calculate effective multiple and decide overall which lane will be the best choice?

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

      Can you explain case 4? what do you mean by look down the line to find the first x in lane 1 or lane 2?

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

        Basically to decide whether to move extras to lane 1 or lane 2, you want to see which one of them has a multiplication that comes first after that point. All of the steps are easy to prove so I would recommend trying to do that. If you need help you can ask me.

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

      By the way, you can optimize case 4 so that it's not the bottleneck of your solution. There's two routes you can take for the same multiplier subcase: either you treat them as extras that doubled or tripled (and still keep the same non-commital aspect of "looking down the line"), or you preprocess "looking down the line". The first of these routes is actually very similar to your Case 3 (you don't commit people to one lane and just accumulate extras). Either way, you get an O(n) solution.

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

I made a greedy solution guess for div2 D without proof and it passed pretest, now fingers crossed for system test.

Also I struggled with what question B was actually trying to say.

Edit : yikes !!! div2 D passed system test. I am not proud, but I will sleep happily now.

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

    No way, greedy worked for D? I calculated and it got disproved in the given TCs, can you tell me what you mean by greedy here?

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

      yeah waiting for system tests first ha ha .. not sure it is going to make it

      but my greedy was do brute force BFS for all possible state but at a layer only take max values in front of a gate.. so every layer of BFS can only have max 2 states. eg if possible state in front of gate were (5,3), (4,2), (1,19), (2, 10)

      max in front of operation 1 is 5 and max in front of operation 2 is 19

      so I only take (5,3) and (1,19) to next BFS level ..so my BFS don't explode to 2^n

      not sure of correctness though .. fingers crossed

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

        I see, all the best.

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

        did not understand, please elaborate your approach in detail

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

          you can check my submission for the code..

          I will only give brief idea.. first idea was to do 2^n BFS .. basically at every step ... get all states ... so what are these states

          eg. if 1st gate has A people and 2nd has B .. and operation on 1st gate is op1 and on second is op2 ... this state is denoted by {A,B}

          then results after going through the gates will be op1(A) and op2(B) ... now diffs are d1 and d2 where d1 = op1(A) - A and d2 = op2(B) - B, these diffs are new people which appeared , and these need to be rearragned for remaining gates

          now first assumption I made was we send all people to same gate .. so possible next states are {A+d1+d2, B} ( we send all new people to gate 1) and {A, B+d1+d2}

          now if we do this completely every layer will have 2^(layer) states and overall 2^n

          I made another assumption that I will pick only 2 states in a layer which gives me maximum people in front of a gate .. so now every layer has at max 2 states, which is what I did. example of this choice is in previous comment.

          what I am not sure is why this assumption is correct, but because it passed given test cases I submitted to try my luck.

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

            ok got it. i was thinking of the same approach but not with 2 states at each level/gate, i was thinking of trying all the possible distributions of the newly appeared persons that came out of the gate.

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

    what is your idea of greedy?

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

      Suppose you are currently in i-th gate. Now consider closest gate j where i<j and one of its door has 'x'. Then you always have put your extra people on that lane. Because once you reach that gate you will have duplicate of extra people(so you can place it on other lane if you want) but if you were to put it on the other lane then you would only have the amount of extra people you made.

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

Div2 D was like its almost in my hands but i cant catch it haha

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

Why is test 1 of div1 b not an example

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

A contest with an interesting interective problem! I have solved my first Div.2E :)

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

Hello guys, I have kind of just started. Can someone please tell after the contest ends where can I find the solutions for it...

and are there any good subreddits, discords or telegram chats that discuss the solutions after the contest is over

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

How to solve C in div 2?

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

I liked some of the problems.

  • A: very guessy problem, I think As can be much better than that
  • B: neat observation problem, B is definitely in its place
  • C: decent problem, spent a lot of time figuring how to make a new element unique
  • D: my approach failed and I was struggling to find my mistake. Btw, I think that under the given constraints the answer can be larger than uint64_t, which is very strange (just try n=30 and all gates x 3 x 3). UPD. No, it's not. It was a bug in my testcase

Not the worst contest. The statements were mostly clear and easy to understand.

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

    The maximum for D is actually slightly under the limit.

    The actual maximum is n=30 with a +1000 gate at the start, followed by 29 x3 gates. With 2 sides, your answer comes out to 2002*3^29 which is slightly above 1e17, while 64-bit integer limit is over 1e19.

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

      how did you dp? dp[L][R][i] where L is number of people in lane 1 and R is number of people in lane 2 and i is the ith gate/level we are at.

      1000* (3^29) can be the worst case for L and R which are maybe like ~1e15 so to calculate all dp states wouldnt that give a TLE?

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

    why is my implementation wrong? I trusted the problem statement with the fact that it is guranteed that can have at least 1 such A such that a is the difference of the sums of B and C where both B and C have size n and are made from the array given in the problem. I did swaps to check for a valid one but it gave RTE on test 2 implying there was no such A :(

    CODE-

    pair<v,v> arr(v b){
        int n = b.size()/2;
        sort(b.begin(), b.end());
        v grp1(b.begin()+n, b.end()), grp2(b.begin(), b.begin()+n);
        int diff = abs(accumulate(grp1.begin(), grp1.end(), 0ll) - accumulate(grp2.begin(), grp2.end(), 0ll));
        if(!binary_search(b.begin(),b.end(),diff)) return {grp1,grp2};
        int sum1 = accumulate(grp1.begin(), grp1.end(), 0ll), sum2 = accumulate(grp2.begin(), grp2.end(), 0ll);
        loop(i,0,n){
            int newSum1 = sum1 - grp1[i] + grp2[i], newSum2 = sum2 - grp2[i] + grp1[i],  newDiff = (newSum1 >= newSum2) ? (newSum1 - newSum2) : (newSum2 - newSum1);
            if(!binary_search(b.begin(),b.end(),newDiff)){
                swap(grp1[i], grp2[i]);
                return {grp1, grp2};
            }
        }
        v alt1, alt2;
        loop(i,0,b.size()) (i&1 ? alt2.push_back(b[i]) : alt1.push_back(b[i]));
        int altdiff = abs(accumulate(alt1.begin(), alt1.end(), 0ll) - accumulate(alt2.begin(), alt2.end(), 0ll));
        if(!binary_search(b.begin(),b.end(),altdiff)) return {alt2,alt1};
        int altsum1 = accumulate(alt1.begin(), alt1.end(), 0ll), altsum2 = accumulate(alt2.begin(), alt2.end(), 0ll);
        loop(i,0,n){
            int new1 = altsum1 - alt1[i] + alt2[i], new2 = altsum2 - alt2[i] + alt1[i], newAltDiff = (new1 >= new2) ? (new1 - new2) : (new2 - new1);
            if(!binary_search(b.begin(),b.end(),newAltDiff)){
                swap(alt1[i], alt2[i]);
                return {alt2, alt1};
            }
        }
    }
    
    • »
      »
      »
      19 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      checked your code, the reason why it fails is that it tries to do missing = (large values) — (small values). However, there are some cases where missing can be one of the large or small values. The simplest example is 1 = 2-1, and there are others where it instead hits one of the large values like 6 = 5-3+6-2.

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

    Btw, I think that under the given constraints the answer can be larger than uint64_t, which is very strange (just try n=30 and all gates x 3 x 3)

    Remember that every person can only go through one of the gates in each pair, so in your example the number of people would triple for every pair of gates they go through. As there $$$30$$$ pairs of gates, the total number of people at the end would be $$$2\cdot3^{30}\approx4\cdot10^{14} \lt 2^{49}$$$, which easily fits in a (signed) long long.

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

      in your example the number of people would triple for every pair of gates they go through.

      I understand it like this.

      Gate1: (1, 1) -> (3, 3), $$$ \delta=4 $$$, adjust to (1, 5), we touch only new people when adjusting lanes

      Gate2: (1, 5) -> (3, 15), $$$ \delta =12 $$$, adjust to (1, 17), we touch only new people when adjusting lanes

      $$$...$$$

      After Gate30 the number is much larger than $$$2^{64}$$$

      • »
        »
        »
        »
        19 месяцев назад, скрыть # ^ |
        ← Rev. 2  
        Проголосовать: нравится 0 Проголосовать: не нравится
        • Total number of people at the beginning: $$$1 + 1 = 2 = 2\cdot3^0$$$
        • Total number of people after gate 1: $$$1 + 5 = 6 = 2\cdot3^1$$$
        • Total number of people after gate 2: $$$1 + 17 = 18 = 2\cdot3^2$$$
        • Total number of people after gate 2: $$$1 + 53 = 54 = 2\cdot3^3$$$

        Notice how the total number of people after each gate is $$$3$$$ times larger than before the gate. This must be true, as every person went through a x 3 gate. This means that after gate $$$n$$$ the total number of people will be $$$2\cdot3^n$$$. After gate $$$30$$$, we have $$$2\cdot3^{30} \lt 2^{49}$$$ people, which is not larger than $$$2^{64}$$$.

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

    Today contest was surprisingly good ngl. C was just hard enough but not too hard.

    While D is still beyond me, I try greedy but failed.

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

    did you dp for D? if so what was your dp state?

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

      I tried dp backwards by keeping the lane to which I allocate people (keep the lane with the largest multiplier if at the current lane multipliers are equal or there is only addition). The approach kept giving WA2.

      After the contest I solved using forward dp with the state (left count, right count, current delta). Here you should carefully apply the delta only when you necessarily have to. That is when resulting deltas from applying the previous delta are different when the previous delta is applied to the left and to the right.

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

Wow, 2F/1C was chatgpt-able

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

Why is Div 2C of all satyam343 rounds unrealistically hard? I think it should be at least 1800-1900 today.

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

I got you omsincoconut, you are a big fan of bitmasks

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

If you solve A-C slow you're projected as a specialist.

If you solve A-C fast you're projected as candidate master.

I think this is a bit too much variance for the exact same problems solved

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

please give editorial soon, I think there was some neat idea for div2 E interactive problem because there were only 2 queries , but I couldn't think of any working solution during the contest :(

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

Arcaea is a great game. However this round is not so great as Arcaea.

But I gain rating from this contest, that's good enough.

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

Next time please give a formulized form for fold. In E I was thinking you should fold everything on the left to the right, but it turns out that you can just fold part of it(which made 01110 can be done in one operation). Wasted half and an hour.

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

Looked at the leaderboard for 10 minutes.sumit876 Found this cheaters:

jgiitkgp (problem F) — 309822713 (100% cheater)

d_vaibhavi_singh (problem F) — 309844418 (I think its cheater i am not sure)

2mato_pota2 (problem F) — 309818888 (100% cheater)

sumit876 (problem F) — 309807587 (100000% cheater)

I bet there are a lot more in top 1000. Please take action against these cheaters!

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

Tests for div1A are weak. My contest solution was the following:

put the largest $$$N$$$ values as positive and the rest as negative. If that sum is not valid, for each number between 1 and 40 (I chose this upperbound without thinking too much), try to add it to the array and brute force over all permutations to see if any of them is valid.

This approach breaks in many cases, like the following:

1
2
100 101 102 200

Hack

Also, for div1C I couldn’t get the O(1) formula for the answer on time, and after contest I asked ChatGPT and it gave me the formula right away :(

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

I think the checker for problem C testcases is not correct, please look at this submission

309853299 It says "wrong answer More than one number not found in b". but b = {20, 1} and my answer is a = {19, 20 1}, so i don't think the feedback is right.

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

Do you understand, that this round was a complete failure? C has maximally ugly solution that isn't supposed to be in Div2 C and D isn't much better. One author can't make a good round bcs he just can't discuss problems with anyone and they are were bad.

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

I really liked Div2 C:

  • In order to make sure that the new number being added is unique, it's simplest to try for something less than the smallest or larger than the greatest number in the array.

  • Since, 1 is the smallest number and it can be present in the input, we can really only go larger. The number is permitted to be upto 1e18, while input is limited to 1e9 so this is another hint of the possibility of doing this.

Now, consider that we have found our new number to be X. We can say try to say that:

(X + S1) - S2 = Amax

This is equivalent to the given condition by placing A1 = Amax and putting the terms of the two parts at odd and even indices.

Now, we can try to make X > Amax.

X = Amax + S2 - S1

Since, S2 is sum of N terms each of which is atleast 1, and S1 is sum of N - 1 terms, it is clear that S2 - S1 > 0 is possible. We just have to choose appropriate S1 and S2. It is simplest to choose the first N elements as S1 and the next N - 1 elements as S2. All that's left is rearranging them in the appropriate order.

An implementation is here: https://codeforces.me/contest/2078/submission/309808272

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

for Div2C, we can rewrite the given equation as : a1 + a3 + a5 ... + a2n-1 == a2 + a4 + a6 ... + a2n. That is, sum of odd elements == sum of even elements.

now, let the element to be inserted lay between index i-1 and i. then, the new array (after insertion ) should satisfy the equation we found above. using this, we can find the missing element. if the element we get here is valid, that is a possible answer. else, we move to the next index.

Implementation

but i cant prove this always gives an answer if one exists

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

    it doesn't feel like it should work, you are not taking into consideration the fact that the array b was shuffled, maybe inserting an element somewhere doesnt satisfy the equation but if some element on the left of ind i were to be swapped with some element to the right, the equation becomes satisfied.

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

In problem div2C for the array 1 20 my code outputs 1 20 19 on the 19th case of the test case 2 and the verdict is wrong answer

can someone explain please??

the submission link:

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

Really enjoyed the problems, thanks to the problem setters. Was able to solve div2E just about 5 seconds after the contest ended, I didn't even realize that I was reading the output format incorrectly (I thought we have to put exclamation mark before printing answer, like how it usually is in interactive problems, should've read the statement more carefully :P)

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

For Div2F/Div1C, is there a way to guess the formula during the contest?

  • »
    »
    19 месяцев назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +22 Проголосовать: не нравится
    1. F(l, r) = cnt_1 — cnt_0 (amount of ones — amount of zeroes), therefore, to calculate score, we're maximizing x(F(l,r)-x). This is achieved at x = F(l,r)/2.
    2. In a string with X ones, there are (X a)(n-X b) subsequences with a ones and b zeroes.
    3. We can easily find formulas for the sums of binomial coeficients, e.g. here
    • »
      »
      »
      19 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Hmmmmm, could you describe your approach? I was able to progress a bit, but there seems to be no direct way to obtain a solution from just those identities.

      Through some "proof by I made a bruteforce in python and the pattern seems to match", I was able to obtain the following unproven formula:

      \begin{equation} \sum_{j = 0}^{\Delta}\binom{x}{j}\binom{n — x}{\Delta — j} = \binom{n}{x + \Delta} \end{equation}

      This expression let's us calculate the number of subsequences with the corresponding delta (actually, I've swapped out the x's, so really here it's more like the number of 0s). However, I have been unable to progress from there since any associated expressions end up being to janky (like, we could use the sum over $$$\frac{\Delta^2}{4}\binom{n}{x + \Delta}$$$, but the division is just too out of place (and in any case, completely wrong) and I've yet to find a proper way to even simplify out the inner part).

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

        It's too much to describe in a single comment, but basically, first we realize that score(l, r) = floor(f(l,r)^2/4) (due to that x(c-x) thing i described earlier) and f(l,r) = cnt_1 — cnt_0.

        Now, if we have X ones and Y zeroes (X+Y=n), we get sum over all possible ways to select ones and zeroes as SUM_i (<= X) SUM_j (<= Y) floor((i-j)^2/4) * C(i X) * C(j Y) (by iterating over all possible amount of 0s and 1s in out subsequence).

        Now all you have to do is expand (i-j)^2 (handle even and odd separately), move things that depends on i out of the inner sum and use the fact that SUM_x C(x j) = 2^j, SUM_x [x*C(x j)] = j*2^(j-1), SUM_x [x^2*C(x j)] = (j+j^2)*2^(j-2).

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

          How would you handle the even and odd cases separately? It seems to me that if we try to split the sum in terms of it's even and odd counterparts for the $$$\Delta = |i - j|$$$, then we would lose the ability to use the aforementioned properties. But apart from that, your method is very clear, thank you!

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

            For even, floor((i-j)^2/4)=0.25(i-j)^2=0.25S^2

            For odd, floor((i-j)^2/4)=0.25((i-j)^2-1)=0.25(S^2-1). This is because (i-j)^2 = 1 (mod 4) if (i-j)=1 mod 2.

            If we group S^2 together, we're left with -1 * sum over i-j=odd. This is equal to the amount of subsequences with odd length (all subsequences with even length have an even difference between 1s and 0s, and vice versa), which is 2^(n-1).

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

          have a doubt why you are not considering j to be less than i

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

What was the intuition behind Div1E? How to explain that for single subarray answer is sum of two maximum prefix balances

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

    Read https://codeforces.me/blog/entry/140357?#comment-1253892

    Basically at the start of the process you have range [0, 0], during the process you have a range of sums [l, r] and the events of having to create new operations to be used happens when the sum gets higher than r or lower than l. Graphically, you start at (0, 0), go to (1, a[i]), then (2, a[i]+a[i+1]) and so on while maintining the topmost and lowermost point you've reached. In the end, the cost will be how much you've streched the range so it's the topmost point you've reached (maximum prefix sum) minus the lowest point you've reached (minimum prefix sum).

    Edit: added a badly handdrawn representation of what I mean on paint

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

please release editorial

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +43 Проголосовать: не нравится
A super stupid solution to D1A/D2C
»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Div2D I wonder why the greedy approach that adding the additional people into the nearest lane where mul[l] and mul[r] differ is right. Can anyone help me

Also editorial when

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

    Let's say you had A people if left lane, B people in right lane before some operation, and that operation gave you L people total to be arranged. You put C people to left lane and L-C to right lane (where 0 <= C <= L):

    Left lane: A people, some operation, C people

    Right lane: B people, some operation, L-C people

    Now lets say you see a next operation "+ X * 2" — other operation will follow the same logic. So after this operation you will get X+(B+L-C) new people to arrange:

    Left lane: A people, some operation, C people, operation "+ X", 0 people — total this lane A+C people

    Right lane: B people, some operation, L-C people, operation "* 2", 0 people — total this lane has B+L-C people

    Remaining to arrange: X+B+L-C people

    So if you had C=0, you would have X+B+L number of people to arrange, now lets say you take 0 <= D <= L people and put them to left lane:

    Left lane: A people, some operation, 0 people, operation "+ X", D people — total this lane has A+D people

    Right lane: B people, some operation, L people, operation "* 2", 0 people — total this lane has B+L people

    Remaining to arrange: X+B+L-D people

    If you compare this outcome (with C=0) to the outcome before (with any C) you can see that changing D to be equal to C these outcomes will be equal in number of people in left lane, equal in number of remaining people to arrange, and right lane is not worse (B+L >= B+L-C). So having C=0 and changing D you could have equal or better outcome compare to any other value of C

    Other operations are the same, core trick is to delay arrangement and see which strategy dominates — there will be always one greedy best strategy

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

In Div2 C, I am getting WA on pretest 2, (test case 19) which is n=1, a = {1,20}, and my answer is {19,20,1} ,which is correct according to me, but wrong according to test cases, 309845177, IMG1 IMG 2 IMG 3 PLEASE HELP !!!

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

omsincoconut, you put a confirmed cheater, Manasvi, in top 5. I think for at least the top 5, you could've checked their submissions. Would that be possible?

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

I have a pretty straightforward solution for C which was accepted during the contest.

First we re-model the problem. We have a1=a2-a3+a4....-a(2n+1). We re-write this as a1+a3+a5+...a(2n+1)=a2+a4+a6+...a(2n). Let p=[a1,a3,a5,...a(2n+1)] q=[a2,a4,...a(2n)]. We sort b in descending order, push first n+1 elements into p and the last n-1 into q. Therefore our task is now reduced to finding an a(2n) such that a1+a3+a5+..a(2n+1)=a2+a4+a6+..a(2n).

Claim : a(2n)=(a1+a3+a5+..a(2n+1))-(a2+a4+a6+...a(2n-2)). We have to prove that a(2n) lies between 1 and 1e18 and also it is distinct from all a1,a2,..a(2n-1) and a(2n+1)

Since each of a1,a3,a5...a(2n+1) is greater than a2,a4,...a(2n) by construction, it implies that a(2n)>0. It is also not difficult to see that a(2n) would be upper bounded by 2e14.

To prove its distinctness, assume without loss of generality that a1 is the largest number. Re-writing the equation above we have a(2n)-a1=(a3+a5+..a(2n+1))-(a2+a4+...a(2n-2)). Since there are n-1 terms in each expression on the RHS and again by construction, we have each of a3,a5,..a(2n+1) is greater than a2,a4,..a(2n) the RHS>0 . Therefore, a(2n)-a1>0 or a(2n)>a1. Since a(2n) is greater than the largest of a1,a2,...a(2n-1),a(2n+1), it must be distinct from all numbers.

Therefore we have constructed a=[a1,a2,...a(2n+1)]

Note that the approach of push largest n elements into p and the next n into q would not have worked, mainly because we cannot prove that the number obtained would be distinct.

Apologies for the bad formatting

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

where can i find the solution ? thanks,qwq

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

My solution for Div 2F/ Div 1C, after some calculations, I found a simple formula for the sum of the scores over all non-empty subsequences s. The formula is ((a-b)^2 + (a+b) — 2)* 2^(a+b-4). here 'a' is count of '1's and 'b' is count of '0's, after this, the query part is very simple, just keep track of a and b, then calculate the answer using formula . CODE FOR REFERENCE.. 309928086

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

cant find link to editorial?

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

There are some crazy solutions involving DP and functions for div2/D. Mine was quite simple, just start from the last gate and check at which gate should the additional units go. Definitely x3 is better than x2 which is better than addition. if there are of same precedence (at i'th gate) then send them to the same gate as the prev. (i+1'th gate) one. This can be maintained in a boolean array. Now start from the beginning with (1,1) and keep transferring the units according to the array.

Here is the Java solution: https://codeforces.me/contest/2078/submission/309920626

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

    You can try to prove it informally that it works. The only case that can cause issue that if both the lanes in the last gate have same precedence (i.e. both offer addition or same multiplication). In that case you can send the additional units it to any of the gate it won't change the answer.

    One more thing to observe is that when we are transferring additional units. we transfer ALL the units. I think it's quite obvious! if it's not then dry run a few test cases.

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

Loving this Div.2. One of the best in a while!

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

I don't mind div2F the meaning of this question.Maybe I have caught a cold,my brain is non-thing.This formula don't mind,help me.

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

Task D is super interesting! I see people use BFS, Greedy and DP.

There are so many unique solutions for this.

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

i solved div1A/div2C with random because why not

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

when solution

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

oh man, still no editorial, hope we get it soon.

I want to upsolve interactive problem div2 E ... can someone share some ideas around it ?

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

Where's the solution???@omsincoconut

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

Guys you forgot to wrtie the editoriol

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

How to solve Div2 D?

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

is editorial of this contest is released ??

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

By when can we expect to have the editorial?

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

where is the solution?

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

It's been 2 days editorial is still not up yet!

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

Editorial 404

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

I may die before the editorial. I want to know how to solve D. Please.

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

0/10 round