splay竟然还有库函数。。。
真好~
问题:给一个 NN 表示 个数 1到N1到N ,给一个 KK 表示 次操作,然后 LL,表示从L开始L开始长度为lenlen 这么多个数移动到最前面,问KK次操作后,数列什么样子?
的时候这个库函数的时间是 800800 多msms,但是同学手写的板子能跑到 200200 多 msms
#include"bits/stdc++.h"
#include"ext/rope"
#define out(x) cout<<#x<<"="<<x
using namespace __gnu_cxx;
using namespace std;
typedef long long LL;
const int maxn=1e6+5;
rope<int>ro;
int main()
{
int N,K;
cin>>N>>K;
for(int i=1;i<=N;i++)ro.append(i);
while(K--)
{
int L,len;
cin>>L>>len;
L--;
rope<int>tmp;
tmp=ro.substr(L,len);
ro.erase(L,len);
ro.insert(0,tmp);
}
for(int i=0;i<N;i++)printf("%d ",ro[i]);
printf("\n");
}