Pagini recente » Cod sursa (job #2201892) | Cod sursa (job #364812) | Cod sursa (job #2133314) | Cod sursa (job #156538) | Cod sursa (job #154930)
Cod sursa(job #154930)
var x:array[0..100000]of longint;
aux,n,i,j,max,start, stop:longint;
f,g:text;
begin
assign(f,'xormax.in');
assign(g,'xormax.out');
reset(f);
rewrite(g);
read(f,n);
x[0]:=0;
{(a xor b=c) <=> (a=b xor c) <=> (a xor c=b)}
for i:=1 to n do
begin
read(f,max);
x[i]:=x[i-1] xor max;
end;
max:=0;
for i:=2 to n do
for j:=1 to i-1 do
begin
aux:=x[i] xor x[j];
if (aux=max) and (i<stop) then
begin
start:=j+1;
stop:=i;
end else
if (aux=max) and (i-j-1<stop-start) then
begin
start:=j+1;
stop:=i;
end else
if aux>max then
begin
max:=aux;
start:=j+1;
stop:=i;
end;
end;
write(g,max,' ',start,' ',stop);
close(f);
close(g);
end.