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 | 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 |
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.