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

Обсуждение задачи 1094. Дисплей

Question about E-screen problem....
Послано Ivo 31 май 2001 01:07
1. So when you the cursor is on the end of a text and ">"
is what to do is it space or what.
2. When the coursoris on 80th position and a letter is next
what happens?
3. When cursor is on 80th position ">?"" is to come what
happens  where the cursor goes.
4. When you're on 1st position and "<" is next then what
happens with cursor.

I should always print 80 symbols no matter there are only
10 for example. And if so. What are the other 70 symbols?
Re: Question about E-screen problem....
Послано Dinh Quang Hiep (mg9h@yahoo.com) 31 май 2001 22:21
> 1. So when you the cursor is on the end of a text and ">"
> is what to do is it space or what.

It's a space

> 2. When the coursoris on 80th position and a letter is
next
> what happens?

the letter will be at the 1st position !

> 3. When cursor is on 80th position ">?"" is to come what
> happens  where the cursor goes.

the cursor move to the first place (1st position)

> 4. When you're on 1st position and "<" is next then what
> happens with cursor.
>

it's still at the first position.

> I should always print 80 symbols no matter there are only
> 10 for example. And if so. What are the other 70 symbols?

No, print out the maximum position that the cursor has
reached !

Good luck !

QH@
Are sure that ...
Послано Ivo 1 июн 2001 01:58
Are you sure that I should print tha max position I've
reached? I mean if it is
hi!>>> is the answer "hi!   "
And is the smaple outputwith one/two or three spaces at the
end ?
My program prints

"Look for second hamburger at computer and chairs.790_|"
_ is space
| is the coursor.
you output for the sample is wrong
Послано Dinh Quang Hiep (mg9h@yahoo.com) 1 июн 2001 04:14
the correct one is just like in the text
"Look for second hamburger at computer and chairs.790|"
(| for the cursor !!)

if the input "hi!>>>" so, the correct output is "hi!   ",
but because they said that it's a "one-line
electronic screen", so if the input is
"1234567890>>>...>>" (there are 80 >'s), so the output is
only
"1234567890____..__" (there are 70 _'s)
offcourse _ mean white space.

Good luck for your program!

QH@
I can't find mistake!!! Can you find it???
Послано Ivo 1 июн 2001 20:55
var a:array[1..20000] of char;
    i,j,ind,n,n2,maxpos:integer;
    c:char;
begin
   ind:=0;  n:=0; n2:=0;
   for i:=1 to 20000 do a[i]:=' ';maxpos:=0;
   while not eof do
   begin
      inc(n2);
      while not eoln do
      begin
         inc(n); read(c);
         if c='>' then
           if ind>=80 then ind:=0   else inc(ind)
         else
          if c='<' then
          begin  if ind>0 then dec(ind)  end
          else
            begin
               inc(ind);
               if ind>80 then ind:=1;
               a[ind]:=c;
            end;
         if ind>maxpos then maxpos:=ind;
      end;
      readln;
   end;
   for i:=1 to maxpos do write(a[i]);
end.
Re: I can't find mistake!!! Can you find it??? <= here it's
Послано Dinh Quang Hiep (mg9h@yahoo.com) 2 июн 2001 00:48
i think, in your program u must not let IND reach the value
81, this means whenever it gets to 80, u must immediately
give make it 0 (ind:=0).
Secondly, bout the variable MAXPOS, whenever you update the
varibale IND, u must compare MAXPOS with IND
( if MAXPOS < IND then MAXPOS:=IND )
because IND never reach to 81, ie IND <= 80 so MAXPOS <= 80
too, that all i can explain to you.
btw, i've changed your source code with the above thing, and
get AC with it.
Here is the your changed source

var a:array[1..20000] of char;
    i,j,ind,n,n2,maxpos:integer;
    c:char;
begin
   ind:=0;  n:=0; n2:=0;
   for i:=1 to 20000 do a[i]:=' ';maxpos:=0;
   while not eof do
   begin
      inc(n2);
      while not eoln do
      begin
         inc(n); read(c);
         if c='>' then

{begin changing here}

begin
inc(ind);
if ind > maxpos then maxpos:=ind;
if ind = 80 then ind:=0;
end

{stop changing here}

         else
          if c='<' then
          begin  if ind>0 then dec(ind)  end
          else
            begin
               inc(ind);
               a[ind]:=c;

{here's another change}

if ind > maxpos then maxpos:=ind;
if ind = 80 then ind:=0;

{stop of change}
            end;
      end;
      readln;
   end;
   for i:=1 to maxpos do write(a[i]);
end.

=> Got AC with time = 0.02sec ;)

Ah, btw, why is your A array is to big, you only need it
[1..80], and what about the variable "n2", i don't know you
use it for what :-/

Good luck !

QH@
Thanks veryyy much!!!
Послано Ivo 2 июн 2001 01:22
What I hate about string type of tasks is
that they look easy and they are usually
but there are always some little tricky or
stupid mistakes that every on does!

Thanks againg for helping me not only
in this problem!!!
u're welcome, also, because i'm very interested in posting msg here ;)
Послано Dinh Quang Hiep (mg9h@yahoo.com) 2 июн 2001 03:00
> What I hate about string type of tasks is
> that they look easy and they are usually
> but there are always some little tricky or
> stupid mistakes that every on does!
>
> Thanks againg for helping me not only
> in this problem!!!
Re: Question about E-screen problem....
Послано Foo Chuan Sheng 7 ноя 2001 15:17
>> I should always print 80 symbols no matter there are only
> > 10 for example. And if so. What are the other 70 symbols?
>
> No, print out the maximum position that the cursor has
> reached !
>
> Good luck !
>
> QH@

Technically speaking, the question says that the board is
initially filled with 80 spaces, so shouldn't you have to
output spaces all the way even if your cursor hasn't reached
the end of the screen?