awoo's blog

By awoo, history, 3 years ago, translation, In English

1832A - New Palindrome

Idea: BledDest

Tutorial
Solution (Neon)

1832B - Maximum Sum

Idea: BledDest

Tutorial
Solution (awoo)

1832C - Contrast Value

Idea: BledDest

Tutorial
Solution (Neon)

1832D1 - Red-Blue Operations (Easy Version)

Idea: BledDest

Tutorial

1832D2 - Red-Blue Operations (Hard Version)

Idea: BledDest

Tutorial
Solution (awoo)

1832E - Combinatorics Problem

Idea: BledDest

Tutorial
Solution (BledDest)

1832F - Zombies

Idea: BledDest

Tutorial
Solution (awoo)
  • Vote: I like it
  • +93
  • Vote: I do not like it

| Write comment?
»
3 years ago, hide # |
 
Vote: I like it +40 Vote: I do not like it

imbalanceForces

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

In the editorial of $$$E$$$, it is mentioned that $$$c_{i,0}=\sum_{j=1}^{i}{a_j}$$$. Actually, it should be $$$c_{i,0}=\sum_{j=1}^{i+1}{a_j}$$$ (with $$$c_{0,0}=a_1$$$ and $$$c_{n,0}$$$ is not needed).

Reason:

When we say $$$b_i$$$ (at $$$k$$$) $$$=$$$ $$$b_{i-1}$$$ (at $$$k$$$) $$$+$$$ $$$b_{i-1}$$$ (at $$$k-1$$$), this is true only when $$$k \gt 1$$$, because this will cause the last term in both $$$\sum_{j=1}^{j=i}{{i-j \choose k} \cdot a_j}$$$ and $$$\sum_{j=1}^{j=i}{{i-j \choose k-1} \cdot a_j}$$$ to be $$$0$$$ (as $$$0 \choose x$$$ is $$$0$$$ for positive $$$x$$$). However, this is not the case for the $$$2^{nd}$$$ summation when $$$k=1$$$. The last term will not be eliminated as $$${0 \choose 0}=1$$$.

Submission.

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

    Fixed this issue, thank you!

    The editorial might take a while to update, but hopefully it will show the new version soon.

»
3 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

SorrowForces

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

D1

I see applying Operation 2 $$$n$$$ or $$$n-1$$$ times from begin.

then, $$$k-(n-(n+k) ~\text{mod}~ 2)-1$$$ should be $$$k-(n-(n+k) ~\text{mod}~ 2)+1$$$ ?

Or, $$$k-n+1 + (n+k) \text{mod}~2$$$

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

Problem B:

I don't understand what is 'k — m' maximums, and I don't know what is k when m is the number of operations. Can anyone explain from me pls ??

  • »
    »
    3 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it +3 Vote: I do not like it

    $$$k$$$ is given in the statement. upd: $$$k$$$ is the total number of operations, $$$m$$$ is the number of operations of the first type (when we delete two minimum elements)

    $$$(k-m)$$$ maximums is $$$(k-m)$$$ greatest elements of the array, i. e. $$$(k-m)$$$ last elements in sorted order.

»
3 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

For problem F, quadrangle inequality properties also apply to array partition DP. So we can use Knuth's optimization for a second time on $$$dp$$$, which leads an $$$O(n^2)$$$ algorithm.

This is my submission: https://mirror.codeforces.com/contest/1832/submission/206185565.

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

Hi. can someone please tell me the error in this code which I used without prefix array

#include <bits/stdc++.h>
#define endl "\n"
#define int long long
using namespace std;


int maxRemoval(vector<int> &v){
    int n = v.size(), sum = 0;
    for(int i=0;i<n-1;++i){
        sum += v[i];
    }
    return sum;
}

int minRemoval(vector<int> &v){
    int n = v.size(), sum = 0;
    for(int i=2;i<n;++i){
        sum += v[i];
    }
    return sum;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t;
    cin >> t;
    while(t--){
    
        int n, k;
        cin >> n >> k;
        vector<int> v(n);
        for(int i=0;i<n;++i){
            cin >> v[i];
        }
        sort(begin(v), end(v));
       
        int ans = 0;
        for(int i=0;i<k;++i){
            int s1 = maxRemoval(v);
            int s2 = minRemoval(v);
        
            ans = max(s1, s2);
            if(s1 < s2){
                v.erase(v.end()-1);
            }
            else{
                v.erase(v.begin());
                v.erase(v.begin());
            }

        }
  
        cout << ans << endl;
  
    }
}

It runs correctly for 1st test case but tells that there is wrong answer on test 2 wrong answer 2459th numbers differ - expected: '8', found: '7' I mean does it really check 2459th number. did the testers even count upto that thing. I doubt it. Link to My Submission

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

    I dont think that greede solution is correct. But it also O(n*k) and even it be correct, it gets TLE.

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

Hello guys, I am getting TLE in 1832E - Combinatorics Problem. I don't think I have made any logical errors, but I can't seem to understand why it's giving TLE. Please help :( -> 209759092

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