ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1102. Странный диалог

If I use Pascal,I found the "read" takes too long time.In C,we can use "getc".But in pascal,I don't know how to do.
Is there any algo better than Dp? What does DFA meant?
Could you give me some hint or a good algo?
Thanks for your help.
Waiting for RE.
BYF Re: What does DFA meant? [2] // Задача 1102. Странный диалог 30 авг 2004 16:20
就是有限状态自动机。
ronobe (aka oberon) Re: What does DFA meant? [1] // Задача 1102. Странный диалог 8 мар 2005 17:54
I suppose that this means Deterministic Finite Automat.

> 就是有限状态自动机。
Ну шо тебе ответить
lengyue2005 Re: What does DFA meant? // Задача 1102. Странный диалог 8 июн 2005 13:58
ER~ I'M CHINESE TOO .BUT I DON'T KNOW WHAT DOES "有限状态自动机"MEAN.CAN YOU SAY MORE ABOUT IT??
IceWorld Nor can I solve it by Dp. [1] // Задача 1102. Странный диалог 7 мар 2005 13:50
const
    Inf         ='';
    Outf        ='';
    max            =10;
var
    n            :integer;

Procedure main;
var
    i,j,k       :integer;
    s,bool      :string[max+2];
    alp            :set of char;
    c            :char;
begin
    assign(input,Inf); reset(inpuT);
    assign(output,Outf); rewrite(output);
    readln(n);
    alp:=['p','u','t','o','i','n','e'];
    for i:=1 to n do
    begin
        k:=0;
        s:='';
        bool:='1';
        while not(eoln) do
        begin
            if length(s)>max then begin delete(s,1,1); delete(bool,1,1); end;
            read(c);
            if not(c in alp) then begin bool:='0'; break; end;
            s:=s+c;
            if (c='n') and (length(s)>1) then if (copy(s,length(s)-1,2)='in') and (bool[length(bool)-1]='1')
                then begin bool:=bool+'1'; continue end;
            if (c='n') and (length(s)>4) then if (copy(s,length(s)-4,5)='puton') and (bool[length(bool)-4]='1')
                then begin bool:=bool+'1'; continue end;
            if (c='t') and (length(s)>2) then if (copy(s,length(s)-2,3)='out') and (bool[length(bool)-2]='1')
                then begin bool:=bool+'1'; continue end;
            if (c='t') and (length(s)>4) then if (copy(s,length(s)-4,5)='input') and (bool[length(bool)-4]='1')
                then begin bool:=bool+'1'; continue end;
            if (c='t') and (length(s)>5) then if (copy(s,length(s)-5,6)='output') and (bool[length(bool)-5]='1')
                then begin bool:=bool+'1'; continue end;
            if (c='e') and (length(s)>2) then if (copy(s,length(s)-2,3)='one') and (bool[length(bool)-2]='1')
                then begin bool:=bool+'1'; continue end;
            bool:=bool+'0';
        end;
        if bool[length(bool)]='1' then writeln('YES')
        else writeln('NO');
        readln(s);
    end;
    close(output);
    close(Input);
end;

begin
    main;
end.
CO2 писал(a) 17 июля 2004 14:38
If I use Pascal,I found the "read" takes too long time.In C,we can use "getc".But in pascal,I don't know how to do.
Is there any algo better than Dp? What does DFA meant?
Could you give me some hint or a good algo?
Thanks for your help.
Waiting for RE.
Of course Pascal is OK.
I got AC simply use "read"

DP isn't a good way in this problem,I think.
You can go to  oibh.ioiforum.org  to find some useful tips.