状态: Unaccepted
测评机: Xeond[6]
得分: 80分
提交日期: 2011-6-5 15:53:00
有效耗时: 562毫秒
测试结果1: 通过本测试点|有效耗时218ms
测试结果2: 通过本测试点|有效耗时47ms
测试结果3: 通过本测试点|有效耗时47ms
测试结果4: 通过本测试点|有效耗时63ms
测试结果5: 输出过长|用户输出数据超过标准输出两倍[标准输出1位|选手输出10位]
测试结果6: 通过本测试点|有效耗时47ms
测试结果7: 通过本测试点|有效耗时46ms
测试结果8: 通过本测试点|有效耗时47ms
测试结果9: 通过本测试点|有效耗时47ms
测试结果10: 输出过长|用户输出数据超过标准输出两倍[标准输出1位|选手输出10位]
程序如下:
————————————————————————————————————————
program T2;
type
st=record
str:string;
step:longint;
end;
var
str,strn,changed:string;
g:array[1..7,1..2]of string;
c,i,top,last,w,step:longint;
q:array[0..3000000]of st;
begin
readln(str);
strn:=copy(str,pos(' ',str)+1,length(str)-pos(' ',str));{目标串}
str:=copy(str,1,pos(' ',str)-1);{原串}
c:=1;
readln(g[c,1]);
while g[c,1]<>'' do{g[i,1]原子串,g[i,2]替换子串}
begin
g[c,2]:=copy(g[c,1],pos(' ',g[c,1])+1,length(g[c,1])-pos(' ',g[c,1]));
g[c,1]:=copy(g[c,1],1,pos(' ',g[c,1])-1);
inc(c);
readln(g[c,1]);
end;
dec(c);{c为规则数}
q[1].str:=str;
q[1].step:=0;
top:=0;
last:=1;
while top<=last do
begin
inc(top);
if (q[top].str=strn)and(q[top].step<=10)and(q[top].step<>0) then
begin
writeln(q[top].step);
close(input);
close(output);
halt;
end;
for i:=1 to c do
if pos(g[i,1],q[top].str)<>0 then
begin
inc(last);
w:=pos(g[i,1],q[top].str);
changed:=q[top].str;
delete(changed,w,length(g[i,1]));
insert(g[i,2],changed,w);
step:=q[top].step+1;
q[last].str:=changed;
q[last].step:=step;
if step>10 then
begin
writeln('NO ANSWER!');
close(input);
close(output);
halt;
end;
end;
end;
end.
刚开始队列是30000,只有40分,后来开到3000000,就80了……