Đề bài:
Thuật toán:
- (đang cập nhập thuật toán)
Code:
uses math;
const
tfi='';//castle.inp';
tfo='';//castle.out';
var
fi,fo:text;
n,top1,top2,top3,dem:longint;
tg,kq1,kq2,kq11,kq22:int64;
p,q,a,b:array[0..5001] of longint;
st:array[0..5001] of int64;
procedure nhap;
var i,j:longint;
begin
read(fi,n);
for i:=1 to n do read(fi,a[i],b[i]);
kq2:=high(int64);
end;
procedure swap(var x,y:longint);
var tg:longint;
begin
tg:=x;
x:=y;
y:=tg;
end;
procedure sort(l,r:longint);
var i,j,k,k1,k2:longint;
begin
i:=l;
j:=r;
k:=l+random(r-l+1);
k1:=a[k];
k2:=b[k];
repeat
while (a[i]k1) or ((a[j]=k1) and (b[j]>k2)) do dec(j);
if i<=j then
begin
swap(a[i],a[j]);
swap(b[i],b[j]);
inc(I);
dec(j);
end;
until i>j;
if i=2 then
begin
tg:=int64(st[top3]-st[1])*(v-u);
if tg=kq1 then inc(kq11);
if tg>kq1 then
begin
kq1:=tg;
kq11:=1;
end;
end;
for i:=2 to top3 do
begin
tg:=int64(st[i]-st[i-1])*(v-u);
if tg=kq2 then inc(kq22);
if tga[i] then break
else
begin
inc(top1);
q[top1]:=b[j];
end;
if j>n then break;
k:=j;
while k<=n do
begin
top2:=0;
for k1:=k to n+1 do
if a[k1]<>a[k] then break
else
begin
inc(top2);
p[top2]:=b[k1];
end;
lam(a[i],a[k]);
k:=k1;
end;
i:=j;
end;
writeln(fo,dem);
if dem>0 then
begin
writeln(fo,kq1,' ',kq11);
writeln(fo,kq2,' ',kq22);
end;
end;
begin
assign(fi,tfi);
assign(fo,tfo);
reset(fi);
rewrite(fo);
nhap;
xuli;
close(fo);
end.
Recent Comments