记录编号 |
9971 |
评测结果 |
AAAAAAATTT |
题目名称 |
[AHOI 2006] 可可的文本编辑器 |
最终得分 |
70 |
用户昵称 |
maxiem |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
11.248 s |
提交时间 |
2009-04-23 12:32:37 |
内存使用 |
0.12 MiB |
显示代码纯文本
program editor;
var
o,s,tmp:ansistring;
point,i,n:longint;
code:integer;
procedure ins;
var a,l:longint;
begin
val(copy (o,pos(' ',o)+1,length(o)-pos(' ',o)),l,code);
readln (tmp);
s:=copy(s,1,point)+tmp+copy(s,point+1,length(s)-point);
end;
procedure mov;
var l:longint;
begin
val(copy (o,pos(' ',o)+1,length(o)-pos(' ',o)),l,code);
if l<>0 then point:=l else point:=0;
end;
procedure del;
var l:longint;
begin
val(copy (o,pos(' ',o)+1,length(o)-pos(' ',o)),l,code);
delete (s,point+1,l);
end;
procedure rot;
var i,l:longint;
begin
tmp:='';
val(copy (o,pos(' ',o)+1,length(o)-pos(' ',o)),l,code);
if l<>1 then begin
for i:=point+l downto point+1 do tmp:=tmp+s[i];
for i:=point+1 to point+l do s[i]:=tmp[i-point];
end;
end;
begin
s:='';
assign (input,'editor.in');
reset (input);
assign (output,'editor.out');
rewrite (output);
readln (n);point:=0;
for i:=1 to n do begin
readln (o);
if copy(o,1,6)='Insert' then ins;
if copy(o,1,4)='Move' then mov;
if copy(o,1,6)='Delete' then del;
if copy(o,1,4)='Next' then inc(point);
if copy(o,1,4)='Prev' then dec(point);
if copy(o,1,6)='Rotate' then rot;
if copy(o,1,3)='Get' then writeln(s[point+1]);
end;
close (input);
close (output);
end.