Can someone explain me how to solve problem D of playrix cup using meet in the middle algorithm. Link to problem http://codeforces.net/contest/799/problem/D
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
8 | awoo | 154 |
10 | luogu_official | 150 |
Can someone explain me how to solve problem D of playrix cup using meet in the middle algorithm. Link to problem http://codeforces.net/contest/799/problem/D
Name |
---|
Do a binary search on answer.
Now, how do we check, whether it is possible to take X extensions in order to satisfy the problems condition?
Obviously, we'll consider only taking the greatest X extensions. Use Meet-In-The-Middle. Divide the greatest X extensions into two same-sized multisets A and B (the way you divide doesn't matter).
For each multiset count the following value — maxa[val] is the maximum product of all extentions you spend on extending the first side, while all other extensions are spend on the second side (we are only considering extensions in set A). We can brute forcing all the masks in A. Calculate maxb[] in the same way. Use map < > to store this data.
Now let's iterate over maxa[]. Consider having maxa[p] = q. Now we have to check, whether it is possible to take r extensions for the first side and s extensions for the second size (from the multiset B), so that a·p·r ≥ x and b·q·s ≥ y. We check this by doing a binary search over a maxb[].
So the overall complexity is — (which is actually faster than it sounds, because we don't consider MAX_ANS elements on every binary search step).
I guess, that this solution is not intented...