m:array[1..10000]of longint;
s1,s2:string[20]; c:char;
a:array[1..6,1..2]of string[20];
i,j,k,l,r,n,len:longint;
begin
s1:=’’;
s2:=’’;
repeat
read(c);
if c<>’ ’ then s1:=s1+c;
until c=’ ’;
readln(s2);
for i:=1 to 6 do
for j:=1 to 2 do
a[i,j]:=’’;
i:=0;
while not seekeof do
begin
inc(i);
repeat
read(c);
if c<>’ ’ then a[i,1]:=a[i,1]+c;
until c=’ ’;
readln(a[i,2]);
end;
n:=i;
q[1]:=s1;
l:=1; r:=1;
for i:=1 to 10000 do
m[i]:=0;
repeat
for i:=1 to n do
begin
len:=length(a[i,1]);
for j:=1 to length(q[l])-length(a[i,1])+1 do
begin
s1:=copy(q[l],j,length(a[i,1]));
if (a[i,1]=s1)and(m[l]<10) then
begin
inc(r);
q[r]:=q[l];
m[r]:=m[l]+1;
delete(q[r],j,length(a[i,1]));
insert(a[i,2],q[r],j);
if q[r]=s2 then begin writeln(m[r]); exit; end;
end;
end;
end;
inc(l);
until (l>r);
writeln(’NO ANSWER!’);
end.
第五个点和第十个点。。。我输出no answer错了//
为什么啊?