|  | 
|  | 
| back to board | why i get WA (+) help me please. Posted by Badd  14 Jan 2002 10:58label loop;var stemp : array[1..30500] of char;
 n,l,first,last,now     : longint;
 count                  : longint;
 yeah                   : boolean;
 begin
 count:=0;
 readln(n);
 for l:=1 to n do
 read(stemp[l]);
 readln;
 first:=1;
 last:=n;
 loop :
 while stemp[first]='<' do inc(first);
 while stemp[last]='>' do dec(last);
 now:=first;
 yeah:=true;
 while (now<last) do
 begin
 if (stemp[now]='>') then
 begin
 if stemp[now+1]='<' then
 begin
 stemp[now]:='<';
 stemp[now+1]:='>';
 now:=now+2;
 count:=count+1;
 yeah:=false;
 end
 else now:=now+1;
 end else now:=now+1;
 end;
 if yeah=false then goto loop;
 writeln(count);
 end.
A test for you :) (+) Read the problem carefully. The input string may contain line breaks.For example, this is a correct test:
 4
 >>
 <
 <
 
 I'm sure you'll get AC.
 Good luck!
Re: oh. i got TL can you or anyone gave me a hint? and this is my code Posted by Badd  15 Jan 2002 20:27label loop;var stemp : array[1..30500] of char;
 n,l,first,last,now     : longint;
 count                  : longint;
 yeah                   : boolean;
 begin
 count:=0;
 read(n);
 for l:=1 to n do
 repeat
 read(stemp[l]);
 until (stemp[l]='<') or (stemp[l]='>');
 first:=1;
 last:=n;
 loop :
 while stemp[first]='<' do inc(first);
 while stemp[last]='>' do dec(last);
 now:=first;
 yeah:=true;
 while (now<last) do
 begin
 if (stemp[now]='>') then
 begin
 if stemp[now+1]='<' then
 begin
 stemp[now]:='<';
 stemp[now+1]:='>';
 now:=now+2;
 count:=count+1;
 yeah:=false;
 end
 else now:=now+1;
 end else now:=now+1;
 end;
 if yeah=false then goto loop;
 writeln(count);
 end.
What is the answer Posted by OZone  20 Feb 2002 20:07What is the answer - 0 or 4? | 
 | 
|