AT1219 歴史の研究

题意

关于回滚莫队见这篇博客。

code:

#include
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int maxt=350;
int n,Q,t,num,block,nowl,nowr;
int a[maxn],b[maxn],L[maxt],R[maxt],pos[maxn],cnt[maxn],tmpcnt[maxn];
ll nowans;
ll ans[maxn];
struct Query{int l,r,id;}qr[maxn];
inline bool cmp(Query x,Query y){return (pos[x.l]==pos[y.l])?(x.rR[pos[qr[i].l]])erase(nowr--);
            while(nowlqr[i].l)add(--nowl);
        ans[qr[i].id]=nowans;
        while(nowl

你可能感兴趣的:(AT1219 歴史の研究)