牛客网多校3 Shuffle Cards(rope)

题目:一个1,2,3.....n的序列,m个操作,每个操作把数组的 L开始往后len长度的串整体移到最前面然后前面的往后移动。

比赛时队友粘了个伸展树模板过了,很纳闷看提交记录别人的代码长度比我们的少10几倍啊!!!wtf??rope好牛逼啊!学一个别人的rope。emmm感觉所有人都知道就我不知道。

#include <bits/stdc++.h>
#include<ext/rope>
using namespace std;
using namespace __gnu_cxx;
rope<int>we;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        we.push_back(i);

    int a,b;
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&a,&b);
        we=we.substr(a-1,b)+we.substr(0,a-1)+we.substr(a+b-1,n-a-b+1);
    }
    for(int i=0;i<n;i++)
        printf("%d ",we[i]);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/dllpxfire/article/details/81226970
今日推荐