|
|
back to boardCOMPILATION ERROR 10 times: Compilation Error. WHY???? const MAXN = 10000; var A: array[0..9999] of integer; i,j,N, ii, LL,ni: integer; fl : boolean; s : array [0..10001] of boolean; as,bs:array [1..6000] of integer; procedure BinarySearch(x: integer); var p, q, i, L: integer; begin p := 0; { Left border of the search } q := N-1; { Right border of the search } L := 0; { Comparison counter } while p <= q do begin i := (p + q) div 2; inc(L); if A[i] = x then begin if (i=ii) and (L=LL) then fl := true; exit; end; if x < A[i] then q := i - 1 else p := i + 1; end; end; begin for i:= 0 to maxn-1 do a[i] := i; fillchar(s,sizeof(s),false); read(ii, LL); for n := 1 to 10000 do begin fl := false; BinarySearch(ii); s[n]:=fl; end; ni := 0; i := 1; while i <= 10000 do begin while ((not s[i]) or (s[i-1])) and (i <= 10000) do inc(i); if i = 10001 then continue; j := i; while s[j] do inc(j); inc(ni); as[ni] := i; bs[ni] := j-1; i := j; end; writeln(ni); for i := 1 to ni do writeln(as[i],' ',bs[i]); end. lITLE ERRORAND YOU GOT AC. program Project1; {$APPTYPE CONSOLE} uses SysUtils; const MAXN = 10000; var A: array[0..9999] of integer; i,j,N, ii, LL,ni: integer; fl : boolean; s : array [0..10001] of boolean; ad,bs:array [1..6000] of integer; procedure BinarySearch(x: integer); var p, q, i, L: integer; begin p := 0; { Left border of the search } q := N-1; { Right border of the search } L := 0; { Comparison counter } while p <= q do begin i := (p + q) div 2; inc(L); if A[i] = x then begin if (i=ii) and (L=LL) then fl := true; exit; end; if x < A[i] then q := i - 1 else p := i + 1; end; end; begin for i:= 0 to maxn-1 do a[i] := i; fillchar(s,sizeof(s),false); read(ii, LL); for n := 1 to 10000 do begin fl := false; BinarySearch(ii); s[n]:=fl; end; ni := 0; i := 1; while i <= 10000 do begin while ((not s[i]) or (s[i-1])) and (i <= 10000) do inc(i); if i = 10001 then continue; j := i; while s[j] do inc(j); inc(ni); ad[ni] := i; bs[ni] := j-1; i := j; end; writeln(ni); for i := 1 to ni do writeln(ad[i],' ',bs[i]); end. |
|
|