PROBLEM LINK: Rick Tries CP
PREREQUISITES: Segment tree, Lazy Propogation
This Problem Was a Simple adaptation of Segment Tree + Lazy propagation on a 2*N array. As segment tee can be applied on an array, not on a range from 1 to 10^15, we use coordinate compression to use the points as elements of an array. After that, it’s just using the update function for every Query, and after all the queries, we use the range function to find the value at every required point. For better understanding on the logic of update function and range function, please refer my code.
Segment tree + lazy propagation Study Material:
Expected solution: here