一般说的浅谈是永远不会短的
然后$qwq$本宝宝并不想讲实现原理 会用就行了呗
然后方便起见,本文规定数组$a$的第$1$位为$a[0]$
并且本文的所有$debug$为了方便看到我们$rope$长度之后的东西,会多输出若干位(看$debug$程序就懂了)
所以一些输出可能跟我的不一样(比较明显,显然数组越界)
进入正题
首先需要的头文件:
#include<ext/rope>
需要的命名空间
using namespace __gnu_cxx;
之后声明一个$rope$
rope</*这里面是填变量类型*/> ro;
如果命名空间是$std$的话可以这么写:
__gnu_cxx::rope</*变量类型*/> ro;
这里以变量类型为$int$的$rope$来举例
前置技能是知道怎么访问:
获取$ro$的第$i$位是$ro[i-1]$ 因为$rope$是从$0$开始的
#include<iostream> #include<cstdio> #include<algorithm> #include<ext/rope> using namespace std; __gnu_cxx::rope<int>ro; int n,m,p; void debug(int len) { for(int i=0;i<=len;i++) printf("%d %d \n",i,ro[i]);//输出0~len这len+1位存的是啥 puts(""); return ; }