ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1102. Strange Dialog

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.