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 1094. E-screen

Tolstobrov Anatoliy[Ivanovo SPU] Why my program wrong in 4 test? give some tests!!! help plz (s menya pivo) [6] // Problem 1094. E-screen 7 Jun 2005 02:44
var
s:string;
m:array[-50000..50000]of char;
i,min,max,u:longint;

begin
readln(s);
u:=0;min:=90001;max:=-90001;

for i:=1 to length(s) do
  begin
   if s[i]='<' then dec(u);
   if u<1 then u:=1;
   if s[i]='>' then inc(u);
   if (s[i]<>'>')and(s[i]<>'<') then
                                begin
                                 m[u]:=s[i];
                                 if min>u then min:=u;
                                 if max<u then max:=u;
                                 inc(u);
                                end;
  end;

for i:=min to max do write(m[i]);

end.
The length of the screen is 80 symbols!
Tolstobrov Anatoliy[Ivanovo SPU] man give test plz. With my mistake! [2] // Problem 1094. E-screen 8 Jun 2005 01:17
man give test plz. With my mistake!
it4.kp Re: man give test plz. With my mistake! [1] // Problem 1094. E-screen 8 Jun 2005 05:12
Here is a piece of code:
...........................................

s, res: string;
p, i: integer;

readln(s);
res:= '';
for i:=1 to 80 do res:= res+' ';
p:= 1;
for i:=1 to length(s) do begin
  if s[i]='<' then begin
    dec(p);
    if p<1 then p:=1;
  end else if s[i]='>' then begin
    inc(p);
    if p>80 then p:=1;
  end else begin
    res[p]:= s[i];
    inc(p);
    if p>80 then p:=1;
  end;
end;
write(res);
...............................................

Something like that will give U AC.
Alexander Samal Re: man give test plz. With my mistake! // Problem 1094. E-screen 6 Sep 2009 04:26
I'm not sure, but I think it is because signs are "(:;-!?.,)"
1) Use a line long 80

2) Read out symbols
In my case, the problem was that after writing char out I didn't wrap the cursor back to the beginning.