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

help me why i get wa
Posted by Aybek Bukabayev 23 Feb 2006 10:42
var
a : array[1..30000]of char;
ch:char;
n,i,c:longint;

procedure init;
begin
    readln(n);c:=0;
    for i:=1 to n do begin
    read(a[i]);
    end;
end;

procedure solve;
var q:boolean;
    j:longint;
begin
    i:=1;  q:=true;j:=0;
    while q and (j<1000000000) do begin
    q:=false;i:=1;inc(j);
    while i<=n do begin
        if (a[i]='>')and(a[i+1]='<') then begin
            a[i]:='<';a[i+1]:='>';inc(i);
            q:=true;inc(c);
        end;
        inc(i);
       end;
    end;
    if j<1000000000 then
    write(c) else write('NO');
end;

begin
    init;
    solve;
end.

Edited by author 23.02.2006 15:39
Re: help me why i get wa
Posted by Aybek Bukabayev 25 Feb 2006 14:26
Aybek Bukabayev wrote 23 February 2006 10:42
var
a : array[1..30000]of char;
ch:char;
n,i,c:longint;

procedure init;
begin
    readln(n);c:=0;
    for i:=1 to n do begin
    read(a[i]);
    end;
end;

procedure solve;
var q:boolean;
    j:longint;
begin
    i:=1;  q:=true;j:=0;
    while q and (j<1000000000) do begin
    q:=false;i:=1;inc(j);
    while i<=n do begin
        if (a[i]='>')and(a[i+1]='<') then begin
            a[i]:='<';a[i+1]:='>';inc(i);
            q:=true;inc(c);
        end;
        inc(i);
       end;
    end;
    if j<1000000000 then
    write(c) else write('NO');
end;

begin
    init;
    solve;
end.

Edited by author 23.02.2006 15:39