BZOJ3489 A simple rmq problem
乍一看不会。 想了想,求出每一个数的前一个相同的数的位置和后一个相同的数的位置,然后询问就是L<=i<=R && next[i]>=R && last[i] <= L的最大的a[i]。这三层树套树啊!? 好像不带修改,那可以把一个Log的树优化成1的前缀和。 然后最值不满足减法,所以就把L<=i<=R拿动态建的线段树套里面好了。 卡空间400+MB过了,我对拍的大数据把网上的某人的程序干掉了哈哈。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; struct seg { int v, ls, rs; }; const int maxn = 100009; const int maxnd = maxn * 409; int n, m, a[maxn], v[maxn], ls[maxn], nx[maxn], o[maxn]; int t[maxn], sp; seg sl[maxnd]; inline bool cmpO(const int& a, const int& b) { return ls[a] < ls[b]; } int getLa(int l0) { int l = 1, r = n;...