Pagini recente » Cod sursa (job #111367) | Cod sursa (job #2388232) | Cod sursa (job #2137041) | Cod sursa (job #3165428) | Cod sursa (job #715175)
Cod sursa(job #715175)
var a:array[1..131072] of longint;
n,m,c1,c2,op,el,i:longint;
f,g:text;
function div_imp(p,q:integer):integer;
var max1,max2,mij:integer;
begin
if p=q then div_imp:=a[p] else
begin
mij:=(p+q)div 2;
max1:=div_imp(p,mij);
max2:=div_imp(mij+1,q);
if max1>max2 then div_imp:=max1 else div_imp:=max2;
end;
end;
procedure schimb(c,b:longint);
var aux:longint;
begin
aux:=a[b];a[b]:=c;a[c]:=aux;
end;
begin
assign(f,'arbint.in');reset(f);assign(g,'arbint.out');rewrite(g);
read(f,n,m);
for i:=1 to n do
read(f,a[i]);
for i:=1 to m do
begin
read(f,op);
if op=0 then begin read(f,c1,c2);writeln(g,div_imp(c1,c2)); end
else begin read(f,c1,c2); schimb(c1,c2); end;
end;
close(f); close(g);
end.