Pagini recente » Cod sursa (job #2272987) | Cod sursa (job #2021655) | Cod sursa (job #126563) | Cod sursa (job #1821997) | Cod sursa (job #183219)
Cod sursa(job #183219)
var a:array[1..20000000] of longint;
b:array[0..22] of longint;
st,dr,z,i,x,y,n,max,j:longint;
f,g:text;
procedure fill;
var poz:longint;
begin
poz:=1;
for j:=b[0] downto 2 do begin
poz:=poz shl 1+b[j];
a[poz]:=-1;
end;
poz:=poz shl 1+b[1];
a[poz]:=i;
end;
procedure caut;
var poz,i:longint;
begin
poz:=1;
for i:=b[0] downto 1 do begin
if a[(poz shl 1)+(b[i] xor 1)]<>0 then begin
y:=y shl 1+b[i] xor 1;
poz:=(poz shl 1)+(b[i] xor 1);
end
else begin
y:=y shl 1+b[i];
poz:=poz shl 1+b[i];
end;
end;
z:=a[poz];
end;
begin
assign(f,'xormax.in'); reset(f);
assign(g,'xormax.out'); rewrite(g);
read(f,n);
read(f,x);
y:=x; b[0]:=22; i:=1;
for j:=1 to b[0] do begin
b[j]:=y and 1;
y:=y shr 1;
end;
max:=-1;
fill;
for i:=2 to n do begin
read(f,y);
x:=x xor y;
y:=x;
for j:=1 to b[0] do begin
b[j]:=y and 1;
y:=y shr 1;
end;
y:=0;
caut;
if x xor y>max then begin
max:=x xor y;
st:=z;
dr:=i;
end;
fill;
end;
writeln(g,max,' ',st+1,' ',dr);
close(f); close(g);
end.