|
|
вернуться в форумTimelimit in 3rd Test :( Послано Rh1N0 19 фев 2007 16:27 Why timelimit on 3rd test? My program listing: program hack; var ar : array[1..100] of byte; i,n : integer; word : string; begin readln(word); n := length(word); for i:=1 to n do begin ar[i] := ord(word[i]) - 97; end; begin for i:=2 to n do begin if ar[i] < ar[i-1] then while ar[i] < ar[i-1] do ar[i]:= ar[i] + 26; end; end; for i:= 0 to n-2 do begin ar[n-i] := ar[n-i] - ar[n-i-1]; end; ar[1] := ar[1] - 5; for i := 1 to n do begin word[i] := chr(97+ar[i]); end; writeln(word); end. Re: Timelimit in 3rd Test :( ar : array[1..100] of byte; Your array overflow while ar[i] < ar[i-1] do ar[i]:= ar[i] + 26; this cycle becomes infinity Example ar[1]:=240+26 =10 Edited by author 19.02.2007 17:34 |
|
|