Блог пользователя USACOW

Автор USACOW, история, 18 месяцев назад, По-английски

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

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
18 месяцев назад, # |
Rev. 4   Проголосовать: нравится +7 Проголосовать: не нравится

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.

  • »
    »
    18 месяцев назад, # ^ |
    Rev. 3   Проголосовать: нравится +8 Проголосовать: не нравится

    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.