天天看點

ext/rope STL平衡樹的用法 2018牛客網 多校第三次 C

給出一個序列 有一些切割其中一部分區間然後前移的操作

長度為1e5 操作數也是1e5

https://www.nowcoder.com/acm/contest/141/C

#include<bits/stdc++.h>
#include<ext/rope>
using namespace std;
using namespace __gnu_cxx;
rope<int>c,b;
int num;
signed main()
{

    int n,m;
    cin>>n>>m;
    for(int i=;i<=n;i++)
        {

            c.push_back(i);
        }
    while(m--)
    {
        int l,r;
        scanf("%d%d",&l,&r);

       c = c.substr(l-,r)+c.substr(,l-)+c.substr(l+r-,n);
    }
    int top  =;
    for(auto k:c)
    {
        if(top)top =;
        else printf(" ");
        printf("%d",k);
    }
    return ;
}