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 1135. Recruits

Badd why i get WA (+) help me please. [3] // Problem 1135. Recruits 14 Jan 2002 10:58
label 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.
shitty.Mishka A test for you :) (+) [2] // Problem 1135. Recruits 14 Jan 2002 16:31
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!
label 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.
OZone What is the answer // Problem 1135. Recruits 20 Feb 2002 20:07
What is the answer - 0 or 4?