Hi, How to solve D, G, and J, from Tishreen-CPC 2018
Or what should I learn in order to solve them?
Any hint would be much appreciated <3
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Hi, How to solve D, G, and J, from Tishreen-CPC 2018
Or what should I learn in order to solve them?
Any hint would be much appreciated <3
Name |
---|
D — sweep left to right doing dp storing best answer with final interval picked, hold 2d segtree (rather segtree where each node has pbds ordered set) for transitions to fit c_i and x_i condition, process dp value of interval when get to its left point but don't add to segtree until right point. I wonder can we do without 2d segtree/use more greedy ideas?
G — For number of color with only single type 1 added then type 2 query, number of colors can be reworded total subsets of type 1 added minus total subsets completely outside query range, so can reword to finding number of subsets added completely outside query range. This can be done with some casework based on how intersects and using 2d segtree: each interval completely outside add 2^len, interval partially intersect add 2^[right position] then divide out 2^[right position of query], completely contain query add 2^len then divide out 2^[query len]. Once again, can we do without 2d segtree?
J — use cartesian tree on values of array and small to large merge of trie's going up the tree, for every subtree (ie fixed max on range) can get number of pairs corresponding to intervals with greater xor when merging tries.
Thanks a lot!
I will try to get them accepted and will give some feedback if that happened.
Especially if the implementation didn't require a 2d segtree.
UPD1:
D Accepted!!
The idea is exactly as you've explained. The only difference is that instead of using ordered_set I compressed the C_i values and used them as indexes in the 2d segment tree.