|
|
back to boardmy dp program is TLE!!!!!!! program hrh; const s2:array[1..6] of ansistring=('in','out','output','puton','one','input'); var n:longint; f:array[0..1000000] of boolean; s:ansistring; procedure init; var i,j,k,now:longint; begin readln(n); for i:=1 to n do begin readln(s); now:=0; f[0]:=true; if (pos(' ',s)<length(s))and(pos(' ',s)<>0) or (s='') then begin writeln('NO'); continue; end; for j:=1 to length(s) do begin f[j]:=false; for k:=1 to 6 do if (j-length(s2[k])>=0) then begin if (copy(s,j-length(s2[k])+1,length(s2[k]))=s2[k]) and f[j-length(s2[k])] then f[j]:=true; end; if f[j] then now:=0 else inc(now); if now>=6 then begin f[length(s)]:=false; break; end; end; if f[length(s)] then writeln('YES') else writeln('NO'); end; end; begin init; end.
I think my program may be right,but how to AC it is still a big problem, who can help me???????? |
|
|