|
|
вернуться в форумОбщий форумWHY ON EART DO I GET COMPILATION ERROR. THE PROBLEM IS 1135 Var Ch : Char; N,I,C : Word; M : Array[1..30000]of Char; Moves : Longint; Found : Boolean; Tot : Longint; BEGIN Readln(N); For I:=1 To N Do Begin Read(Ch); If (Ch='<')or(Ch='>') then M[I]:=Ch else Dec(I); End; Found:=False;Moves:=0;Tot:=0; While Not Found Do Begin C:=0; For I:=1 To N-1 Do If (M[I]='>')and(M[I+1]='<') then Begin Inc(C); Inc(Tot);M[I]:='<'; M[I+1]:='>';Inc(I); End; If C=0 then Found:=True; Inc(Moves); If (Moves*N)>=10000000 then Begin Writeln('NO'); Halt; End; End; Writeln(Tot); END. For-control variable 'I' should not be changed in the loop. Послано abc 22 ноя 2001 14:24 Subj Re: WHY ON EART DO I GET COMPILATION ERROR. THE PROBLEM IS 1135 I don't know why does your program get Compilation Error, I think that sometimes "Wrong answer" causes "Memory limit" or "Compilation error". I just want to tell you, that this problem has a very simple decision - linear; when you read the n-th simbol('<' or'>') you already know the answer. Think about this. I saw you have submitted Problem 1139 - City blocks. I Always get Wrong Answer on it. Here is my idea: Let K=(m,n); m1:=m div k; n1:=n div k; Then the answer is the same as the answer for m=m1 and n=n1 times K. Have a look at my program please, I really want to submit it. Here is it: > Var Ch : Char; > N,I,C : Word; > M : Array[1..30000]of Char; > Moves : Longint; > Found : Boolean; > Tot : Longint; > BEGIN > Readln(N); > For I:=1 To N Do > Begin > Read(Ch); > If (Ch='<')or(Ch='>') then M[I]:=Ch else Dec(I); > End; > Found:=False;Moves:=0;Tot:=0; > While Not Found Do > Begin > C:=0; > For I:=1 To N-1 Do > If (M[I]='>')and(M[I+1]='<') then > Begin Inc(C); > Inc(Tot);M[I]:='<'; M[I+1]:='>';Inc(I); End; > If C=0 then Found:=True; > Inc(Moves); > If (Moves*N)>=10000000 then Begin Writeln('NO'); > Halt; End; > End; > Writeln(Tot); > END. THANKS! |
|
|