Rope函数
类似指针链表的操作,时间复杂度会在n*(n^0.5),可以在很短的时间内实现快速的插入、删除和查找字符串
在g++头文件中,<ext/rope>中有成型的块状链表,在using namespace __gnu_cxx;空间中,类似string函数的操作其操作十分方便。
基本操作:
rope T;
T.push_back(x);//在末尾添加x
T.insert(pos,x);//在pos插入x
T.erase(pos,x);//从pos开始删除x个
T.copy(pos,len,x);//从pos开始到pos+len为止用x代替
T.replace(pos,x);//从pos开始换成x
T.substr(pos,x);//提取pos开始x个
T.at(x)/[x];//访问第x个元素
printf("%d\n",T[i]) cout<<T<<endl; 输出T[i] 输出T;
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<ext/rope>
using namespace std;
using namespace __gnu_cxx;
const int maxn=2e5+7;
const int INF=0x3f3f3f3f;
const double ESP=1e-8;
int a[maxn];