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

Автор shashwatchan, история, 5 лет назад, По-английски

Thank you for participating, and I hope you enjoyed the problems! Once again, we're sorry about the round being unrated.

Also, here are video editorials by BRCode:

Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...

This problem was set by Anti-Light and prepared by knightron00

Tutorial is loading...
Tutorial is loading...
Разбор задач Codeforces Round 682 (Div. 2)
  • Проголосовать: нравится
  • +167
  • Проголосовать: не нравится

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

How to solve the C problem with dfs?

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

Nice Problem Set :). Got to learn few new things.

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

D was a nice one :)

»
5 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +20 Проголосовать: не нравится

D was very good (well, every problem was very good actually). Looking forward to your next rounds!

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

    Could you please explain D?

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

      Let us assume that N is odd and a window of 1 x 3 that moves on the 1 x N given array. The window starts from i=1 and moves forward by +2 in each step, precisely, the left end moves on the odd position after each step until the rightmost end is at N. So, in general we can observe the pattern with N=7, let, A = [a, b, c, d, e, f, g], then after applying the above operation(move window at i=1,i=3,i=5), you will get the following array B = [x, x, y, y, z, z, z]. So, now we will again apply the above "window" operation from i = N - 2(right end) and move downwards on the odd points until the left end of the window touches i=1. So the final array will be C = [z, z, z, z, z, z, z]. Total number of operations are n/2 + n/2 = n-1 (assumed that n is odd).

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

        If $$$N$$$ is even then you must think a little more. First it's easy to notice that the xor of the whole array stays the same in all the progress. Then in an correct array with all its elements equal the xor of its elements is 0. So if the xor of its elements it's not equal to 0 then it's impossible. Else you can make the same approach that TheBigBool mentioned above without using the last element. You will end with $$$A = [a,a,a,...,a,b]$$$ (odd number of a and one b). So the xor of the whole array is a xor b and because the xor of the whole array is 0 then a is equal to b and we don't need to make other operations.

        PS:Really like that problem!

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

        Thank uuuuu!

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

    .................................................

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

Is there anyone who solved problem C using 2SAT method?

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

Good questions

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

C is so elegant, I can't believe I missed that observation

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

Nice editorial shashwatchan. No BS, straight to the point and easily understandable.

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

Well, I came up with observation for C just before I enter here :(

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

Such a good problemset, but it's quite a pity that it unrated :-(

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

problems are soo elegant

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

I have a doubt on C. I am not sure of my solutions time complexity. Could anyone please prove it or hack it. 98306400

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

I need proof for a magical part as suggested in an editorial in Problem-D. How the last element will automatically be the same by applying operations for the first n-1 elements.

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

    Since xor of all elements is zero and since you consider first (n-1) in case of even.
    So you will make first (n-1) elements equal to a particular number let that be x.
    Now let us consider xor of all the elements:
    X=x ^ x ^ x... (n-1) times ^A[n].
    we know since n is even n-1 will be odd.
    So x^ x^ x .. (n-1) times will be x.
    X=x^A[n]
    Since we ensured that X must be 0.
    Property={ a^a=0)
    So
    0=x^A[n];
    so A[n]=x;
    so we have proved all the elements are equal to x.

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

A great problemset ! Requires creativity & clever observations .

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

Nice problem set.

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

The problem set was really nice! Looking forward to more contests from you peeps! :)

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

Is there any math to know how reasonably sure we can be that we have the 2 children of the root after $$$q$$$ queries in problem F? Is 420 deliberately chosen or is it just a meme number?

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

In problem B I am using map to check whether there are duplicates but getting runtime error, pls tell me why is it so?

int main(){
    int tc;
    cin>>tc;
    while(tc--)
    {
        int n;
        cin>>n;
        vector<int> v(n);
        map<int,int> mp;
        int flag = 0;
        for(int i=0; i<n; ++i){
            cin>>v[i];
            if(mp.find(v[i])!=mp.end()){
                flag=1;
                cout<<"YES"<<endl;
                break;
            }
            mp[v[i]]++;
        }
        if(flag==0)
            cout<<"NO"<<endl;
   }
    return 0;
}

https://mirror.codeforces.com/contest/1438/submission/98367651

»
5 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

dont know why my solution is not passing test case 2 for problem C :( can anyone help??thanks soltn :https://pastebin.ubuntu.com/p/m7rG5Rkj5y/ UPD:i got my mistake

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

I have a different approach for problem E.

Let's denote psum[i] as the sum of A[j], for all 1 <= j <= i.

First, we can notice that a + b >= a ^ b. So, we can compute all pairs of indexes l and r, such that A[l] + A[r] >= psum[r-1] — psum[l]. There are at most nlogn of this pairs, because for a fixed l, the valid r's need to be at least two times bigger than the previous one, so there are at most logn for a fixed l, and the worst case is something like 1, 1, 1, 1, 2, 4, 8, ...

Then we can find all such pairs in the following way. First, with simple transformations we can show that a pair is valid if A[r] — psum[r-1] >= -A[l] — psum[l]. Then we can maintain a set of pairs (-A[l]-psum[l],l) and iterate over it while the condition remains true, and for each of these pairs we can check if A[l] ^ A[r] = psum[r-1] — psum[l] and count the number of good pairs.

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

when will rating will get updated ?

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

Here's a bonus problem for A: What if the numbers have to be pairwise distinct? Take $$$n \lt 1000$$$ and the numbers you output must be less than $$$5000$$$.

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

In problem B, for the test case array-{1 2 3}, why is the answer NO, as we have {1,2} and {3} as subarrays having same sum.

»
5 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +94 Проголосовать: не нравится

so there's a funny and unproven solution for task C by Ali_Tavakoli :

for every pair of adjacent elements, we check whether they are equal or not, if they are equal we randomly change one of them which hasn't been changed yet. After we check all the pairs, we check whether the matrix is good or not, if the matrix is good then we have an answer and we are done, if not we will repeat this process until we find a good matrix. he has no proof for this solution but by doing at most 400 repetitions of the algorithm above, he managed to pass the sys tests.

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

Stupid comment ahead I think i might have misunderstood the question "1438D — Powerful Ksenia". So, please help me out here. Let's say the array is 1 2 3 4 Now, the operations are as follows: 1 2 3 4 (initial array) -> 0 0 0 4 -> 0 4 4 4 -> 0 0 0 0. Number of operations = 3, and all array elements are equal. After looking at the editorial, XOR of the above array is 4 and the array length is even. So, answer is "NO". What am i missing?

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

Can you help me explain Problem B?

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

I am not getting problem D.

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

Where can i practice these puzzle problems like 1438C — Engineer Artem? and why are the tags at problem C so weird? constructive algo + 2-SAT + FFT + chinese theorem + flows !!