Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years.
×

# | User | Rating |
---|---|---|

1 | MiFaFaOvO | 3681 |

2 | tourist | 3496 |

3 | apiadu | 3438 |

4 | TLE | 3356 |

5 | LHiC | 3339 |

6 | mnbvmar | 3281 |

7 | 300iq | 3267 |

8 | Radewoosh | 3242 |

9 | yosupo | 3233 |

10 | 1919810 | 3203 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 190 |

2 | antontrygubO_o | 186 |

3 | tourist | 182 |

4 | Radewoosh | 168 |

5 | vovuh | 167 |

6 | pikmike | 165 |

7 | ko_osaga | 161 |

7 | Um_nik | 161 |

9 | rng_58 | 156 |

10 | Petr | 154 |

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial of VK Cup 2018 - Round 3

↑

↓

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/29/2020 07:26:19 (g2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

In the first line of the solution to Div1.D, does the word "formualate" mean "formulate"?

Orz

for div 1 C i chose greedily the minimum value with which we should xor so that we can find the next value in a which is greater than the previous value. I used trie with deletion. Here is the code . http://codeforces.com/contest/967/submission/37730673. Why doesnt it work ?

Tried to find bugs of your solutions but made some mistakes. Sorry for that :(

I got AC in the same way, Here is my solution: http://codeforces.com/contest/967/submission/37739371

but I can't prove it, can someone gives me a proof?

In 967B — Watering System, if we are sorting the holes, shouldn't the complexity be

O(n*log(n)).Sure, it should be

O(nlogn) were we using a comparison based sort. Here though, we can use a linear time sorting algorithm such as counting sort. The complexity in that case would beO(n).Got it. Thanks.

why do we have to sort the holes??

Can someone explain div 2E ? Not able to understand from editorial.

Well, I think div2 E is really an instructive problem though I can't figure out the solution during content.

First, Let's define some functions that can be used in my explanation.

Let

P(x) denote the position of leading bit ofx, 0-indexed. (You can also consider P(x) is the length ofx(binary representation) minus 1). Formally, ifxis in the range [2^{k}, 2^{k + 1}), thenP(x) =k. For example,P(5) = 2, since the leading bit of 5(101b) denotes 2^{2}.Let

F(x,n) denote the nth least significant bit of x, 0-indexed, or, the nth bit from right in the binary representation of x. For example, supposex= 13, thenF(x, 0) = 1,F(x, 1) = 0,F(x, 2) = 1,F(x, 3) = 1, since 13 = 1101b.Note that F(x, P(x)) is always 1.

Then, Let's consider a basic problem. Suppose we have a sequence

a_{1},a_{2},a_{3}, ...a_{k}meeting the strictly increasing condition and the current xor sum iss. We are going to append a numberxto the sequence, making a new xor sum . In which condition, the sequence after appendingxis still strictly increasing, or, in other words,s' >s?The answer is easily to find. if and only if

F(s,P(x)) = 0. For example, ifx= 5 = 101b, to make sequence increasing, the 2^{2}bit of s should be 0. Ifs= 1101b, the 2^{2}bit is 1, then after xor x, the 2^{2}bit will be set to 0, making the sequence decreasing.So we can get such a solution for div 2E. Initially, we consider the sequence is empty and

s= 0, and select a numberxin allnnumbers which meets the conditionF(s,P(x)) = 0. Then append the numberxto sequence and updates. Repeat n times, the answer is got.However, when there are more than one number that is able to select, which one should be selected first? The answer is simple. Just select the one with least P(x).

For example, if the current

s= 1010b, and we have two numbersx_{1}= 101bandx2 = 1 to select. P(x_1)=2, P(x_2)=0. So we should select 1. Why?Because if we first select

x_{2}= 1 (the one with lessP(x)), it will not modify the most significant bit ofx_{1}ins, in other words,F(s,P(x_{1})) will be change by the operation . So that we can appendx_{1}after appendingx_{2}.Otherwise, if

x_{1}is selected first,swill become , then we can't appendx_{2}.Last question, if there are more than one number that is able to select and has least P(x), which one should be selected first? The answer is that it doesn't matter. In that case, we can choose any one of them. Why? Remain for thinking.

Here is my solution:37857270

thanks a lot for sharing this :)

I didn't get the last part,when there are more than one options to choose from,you said we have to choose the one with least p(x),because if we append the one with higher p(x),it may change some zeroes to ones,leaving less "space"(zeroes) for the next number to append.

But there can be only 60 bits,and there will be 100000 numbers,so some of the ones should also get converted to zeroes for the solution.So how does it matter then?

for Div. 2 D i cannot find any special test case in which this type of thinking is wrong : First we can binary search the minimum k1 such that the value of the smallest element >= x1 / k1, after that we can just sort the vector and remember the initial positions of the elements that so we can just verify that the (k1 + 1)-th element >= x2 / (n — k1), because n — k1 is the maximum number of elements for the second service that we divide x2 by. If the inequality is correct then we can just output the solution(meaning we output the indices of elements in the vector because we stored them). Do the same by finding the minimum k2. If you find no solution output No. I think this solution works great because after we sort the array and we make the groups if the smallest elements of the groups respect the condition of value >= x / k then the rest of the elements will respect it, and the smallest element needs to be in a group also, so we can just find ki(where i is 1 or 2, we analyze both), then to be sure that we can build the other group we can find the most suitable case to be biggest n — ki, so we cam=n binary search ki, and to have the largest numbers, so by the observation we made earlier, we can just grab the smallest elements for this group after which we get the most suitable condition, so we get a O(N + log2(N) * 2) = O(N), but i get a WA on test 5 ! can somebody please help me ? This is my submission 39044055