USACOW's blog

By USACOW, history, 17 months ago, In English

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

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
17 months ago, # |
Rev. 4   Vote: I like it +7 Vote: I do not like it

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.

  • »
    »
    16 months ago, # ^ |
    Rev. 3   Vote: I like it +8 Vote: I do not like it

    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.