比赛 |
HAOI2009 模拟试题2 |
评测结果 |
WTTTTTTTEE |
题目名称 |
可可的文本编辑器 |
最终得分 |
0 |
用户昵称 |
辨机ZN |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-04-22 10:12:08 |
显示代码纯文本
program ex(f1,f2);
type
zn=array [1..100000000] of char;
var
a:zn;
f1,f2:text;
i,j,k,p,l,m,n,tot:longint;
s:string;
ch:char;
begin
assign(f1,'editor.in'); reset(f1);
assign(f2,'editor.out'); rewrite(f2);
readln(f1,n);
tot:=0;
for j:=1 to n do
begin
read(f1,ch);
case ch of
'M':begin
for i:=1 to 4 do read(f1,ch);
readln(f1,k);
p:=k+1;
end;
'D':begin
for i:=1 to 6 do read(f1,ch);
readln(f1,k);
for i:=p to p+k do a[i]:=a[i+k];
tot:=tot-k;
end;
'I':begin
for i:=1 to 6 do read(f1,ch);
readln(f1,k);
readln(f1,s);
tot:=tot+k;
for i:=p+k to tot do a[i]:=a[i-k];
for i:=p to p+k do a[i]:=s[i-p];
end;
'R':begin
for i:=1 to 6 do read(f1,ch);
readln(f1,k);
for i:=p to p+k-1 do s[i-p+1]:=a[i];
for i:=k downto 1 do a[p+i-k]:=s[i];
end;
'G':begin
readln(f1);
writeln(f2,a[p]);
end;
'P':begin
readln(f1);
p:=p-1;
end;
'N':begin
readln(f1);
p:=p+1;
end;
end;
end;
close(f1);
close(f2);
end.