|
|
back to boardhelp me why i get wa 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 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 |
|
|