rope 的基本操作

#include <ext/rope>
using namespace __gnu_cxx;
int a[1000];
rope<int> x;
rope<int> x(a,a + n);
rope<int> a(x);
 
x->at(10);
x[10];
x->push_back(x)     // 在末尾添加x
x->insert(pos,x)    // 在pos插入x
x->erase(pos,x)     // 从pos开始删除x个
x->replace(pos,x)   // 从pos开始换成x
x->substr(pos,x)    // 提取pos开始x个

牛客 E。Shuffle Cards

#include<iostream>
#include<ext/rope>
using namespace std;
using namespace __gnu_cxx;
rope<int>a;
int main(){
    int n,m,x,y;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) a.push_back(i);
    for(int i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        a.insert(0,a.substr(x-1,y));
        a.erase(x+y-1,y);
    }
    printf("%d",a[0]);
    for(int i=1;i<n;i++) printf(" %d",a[i]);
    puts("");
}

 

 

相关文章:

  • 2021-12-28
  • 2022-12-23
  • 2022-02-09
  • 2021-10-18
  • 2021-09-07
  • 2021-09-27
猜你喜欢
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2022-01-10
  • 2021-07-27
  • 2021-10-06
相关资源
相似解决方案