Can anyone give a solution sketch for this problem? I've been stuck on it for a while and cannot find a solution online. Thanks!
# | 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 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Can anyone give a solution sketch for this problem? I've been stuck on it for a while and cannot find a solution online. Thanks!
Name |
---|
Look at each topic separately. Let's order the people from highest time to learn to lowest. The person that has the highest cost "dominates" everyone else, so if the set of people has this person then the cost of this topic is the cost of this person. For the second highest, if the set of people has this person and doesn't have the highest cost person, then the cost is the second highest and so on. More generally, the i-th highest cost person will dominate the set in this topic if no person before it is in the set and the i-th person is in the set.
We can solve that directly by using the same idea as prefix sums for range updates but using "SOS dp" instead of prefix sum. To set up a sum over "subset of X" just sum up the value in the position of the mask X. To set up a sum over "subset of X that has some bit Y", sum up in the subset X and subtract in the subset X-{Y}. Complexity O(N * M * logN + 2^N * N)
Could you re-explain the SOS dp? I'm probably just weak with subset dp (and unfamiliar with the idea of using prefix sums in SOS dp), but I don't quite understand how to avoid processing all M categories for each of 2^N subsets.
You know how to use prefix sum for adding V in a subarray [L, R)?
add up V in in position L
subtract V in position R
then after doing prefix sum the subrange [L, R) has +V
Here it's the same thing but with subsets.
We have a mask of bits and for every submask we want to add up v -> add V in position of the mask, then after using "SOS dp" (I hate that name) to have the sum of supermasks, we've added V in every position that's a subset of that mask.
Other than that, this problems asks for adding up V in every subset of that mask that has a certain bit active. To do that, add up V in every subset of that mask (by adding up V in the position of that mask) and subtract V in every subset of that mask that doesn't have that bit active (by subtracting V in the position of that mask — that bit).
Is the complexity reasonable given that there are 100 datasets? This one seems to be expected solution of course.
I'd say it isn't reasonable but it's probably the intended solution (and most likely the fastest solution possible for max tests). Some problems do this thing of "Solve this but we won't tell you if we filled the tests with max tests". I've run into a problem that did this once just to learn that it was also in another OJ without cramming every test into a single file and ended up complaining for a week that the same solution that got TLE in practice passed the way the problem was originally set. So sometimes there are online judge restrictions. Usually it's safe to assume in this kind of situation that the setter just isn't that experienced and you can try solving just for one or a few big tests in a file.
Actually just to make it easier to you I just coded it and it passed in 0.42s :D