具体地,先用数剖拍成 O(logn)O(\log n)O(logn) 个区间查询,然后序列分块处理。
理论上界是 O(nnlogn)O(n\sqrt n\log n)O(nnlogn) 的,但是严重跑不满。
如果能跑满,请给出 hack 的构造方法;如果跑不满,请给出更严格的时间复杂度。