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

Why my program wrong in 4 test? give some tests!!! help plz (s menya pivo)
Posted by Tolstobrov_Anatoliy[Ivanovo SPU] 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.
Re: Why my program wrong in 4 test? give some tests!!! help plz (s menya pivo)
Posted by KingPin 7 Jun 2005 04:36
The length of the screen is 80 symbols!
man give test plz. With my mistake!
Posted by Tolstobrov_Anatoliy[Ivanovo SPU] 8 Jun 2005 01:17
man give test plz. With my mistake!
Re: Why my program wrong in 4 test? give some tests!!! help plz (s menya pivo)
Posted by Виктор Крупко 8 Jun 2005 01:20
1) Use a line long 80

2) Read out symbols
Re: man give test plz. With my mistake!
Posted by KingPin 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.
Re: man give test plz. With my mistake!
Posted by Alexander Samal 6 Sep 2009 04:26
I'm not sure, but I think it is because signs are "(:;-!?.,)"
Re: Why my program wrong in 4 test? give some tests!!! help plz (s menya pivo)
Posted by Rabbit Girl ♥ 4 Aug 2018 10:08
In my case, the problem was that after writing char out I didn't wrap the cursor back to the beginning.