problem link I am doing this question using AVL tree but I am not able to handle the duplicate values in the input. First , I thought of using a vector for each node but that will turn out to be a TLE. Any help would be really appreciated.

Thanks in advance.

use queue in each node to store the ranks

but how will I delete a node ? I mean, if I have a node A (val=10 & rank=1,3,5,10) and its in-order successor node B(val=12 & rank=2,4) . So I have to copy the entire node(val and queue) of node B to node A. Won't it lead to TLE?

yes you are right, i'm sorry.

i did the implementation and it gives TL on test 3. so there must be another way.

seems like

`O(nlgn + mlg(n+m))`

can't fit in the time limit! after some thinking, i approach a way simpler solution, it works as follows:`q[x]`

is a queue that stores all the ranks for value`x`

, to answer query`I x`

just do`q[x].push(currentRank)`

the other queries are the same, you may refer to the code. However it stills TL on the third test. the solution seems to be a way harder.In my opinion O(nlogn) should pass easily. However , only 11 submissions have been there so far for this problem.