
<ext/rope>真是一个牛b的头文件......
| Time Limit: 5000MS | Memory Limit: 165888KB | 64bit IO Format: %lld & %llu |
Description

Input
Output
Sample Input
15 Insert 26 abcdefghijklmnop qrstuv wxy Move 16 Delete 11 Move 5 Insert 1 ^ Next Insert 1 _ Next Next Insert 4 .\/. Get 4 Prev Insert 1 ^ Move 0 Get 22
Sample Output
.\/. abcde^_^f.\/.ghijklmno
Source
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
const int maxn=1024*1024*2+10;
crope txt;
char op[10],str[maxn];
int pos=0;
int main()
{
int T_T,x,y,z;
scanf("%d",&T_T);
while(T_T--)
{
scanf("%s",op);
if(op[0]==‘M‘)
{
scanf("%d",&pos);
}
else if(op[0]==‘I‘)
{
scanf("%d",&x);
y=0;
while(x)
{
char c=getchar();
if(c>=32&&c<=126)
{
str[y++]=c;
x--;
}
}
str[y]=0;
txt.insert(pos,str);
}
else if(op[0]==‘D‘)
{
scanf("%d",&x);
txt.erase(pos,x);
}
else if(op[0]==‘G‘)
{
scanf("%d",&x);
puts(txt.substr(pos,x).c_str());
}
else if(op[0]==‘P‘) pos--;
else if(op[0]==‘N‘) pos++;
}
return 0;
}
BZOJ 1507 Editor,布布扣,bubuko.com
原文:http://blog.csdn.net/ck_boss/article/details/24550345