您的位置:首页 > 其它

bzoj 1507: [NOI2003]Editor

2016-03-13 06:37 393 查看
#include<cstdio>
#include<iostream>
#include<ext/rope>
using namespace std;
using namespace __gnu_cxx;
crope list;
int n,now;
char ch[10],ch1[3000005];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int a1;
scanf("%s",ch);
if(ch[0]!='P'&&ch[0]!='N')
scanf("%d",&a1);
if(ch[0]=='M')
now=a1;
if(ch[0]=='I')
{
for(int i=0;i<a1;i++)
{
ch1[i]=getchar();
for(;ch1[i]=='\n';ch1[i]=getchar());
}
ch1[a1]=0;
list.insert(now,ch1);
}
if(ch[0]=='D')
list.erase(now,a1);
if(ch[0]=='G')
{
list.copy(now,a1,ch1);
ch1[a1]=0;
printf("%s\n",ch1);
}
if(ch[0]=='P')
now--;
if(ch[0]=='N')
now++;
}
return 0;
}


本应是个平衡树,偷懒用了list。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: