看看 sort 有没有把范围写错。(应该没有我这样的笨蛋 =.=)
我 T 了接近一页都是因为 sort(a+1, a+1+n, cmp)。这样会导致莫队排序出错,自然就超时了。改成 sort(a+1, a+1+tot, cmp) 就过了,tot 是我的统计变量。
sort(a+1, a+1+n, cmp)
sort(a+1, a+1+tot, cmp)