|
|
back to boardTo the one who get time limit exceeded.Here my program,hope you to improve yours. var n,i:word; label shi,ab,c,cc,d,dd,e,re; function rm:byte; var ch:char; begin if eoln(input) then rm:=5 else begin read(ch); case ch of 'o': if eoln(input) then rm:=5 else begin read(ch); case ch of 'n':rm:=3; 'u': if eoln(input) then rm:=5 else begin read(ch); if ch<>'t' then rm:=5 else rm:=0; end; else rm:=5; end; end; 'i': if eoln(input) then rm:=5 else begin read(ch); if ch<>'n' then rm:=5 else rm:=1; end; 'p': if eoln(input) then rm:=5 else begin read(ch); if (ch<>'u') or eoln(input) then rm:=5 else begin read(ch); if ch<>'t' then rm:=5 else rm:=2; end; end; 'e':rm:=4; else rm:=5; end; end; end; begin readln(n); for i:=1 to n do begin shi: begin if eoln(input) then begin writeln('YES');goto re;end; case rm of 0,1:goto ab; 2:goto c; 3:goto d; else begin writeln('NO'); goto re; end; end; end; ab: begin if eoln(input) then begin writeln('YES');goto re;end; case rm of 0,1:goto ab; 2:goto cc; 3:goto d; else begin writeln('NO'); goto re; end; end; end; c:if rm=3 then goto shi else begin writeln('NO'); goto re; end; d:if rm=4 then goto shi else begin writeln('NO'); goto re; end; cc: begin if eoln(input) then begin writeln('YES');goto re;end; case rm of 0,1:goto ab; 2:goto c; 3:goto dd; else begin writeln('NO');goto re; end; end; end; dd: begin if eoln(input) then begin writeln('YES');goto re;end; case rm of 0,1:goto ab; 2:goto c; 3:goto d; 4:goto shi; else begin writeln('NO'); goto re; end; end; end; re:readln; end; end. Re: Thanks I know the best answer now, you speed up my learning process |
|
|