Az alábbi letöltési lehetőségek közül választhatsz: (
segítség)
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: us-ascii
Méret: 2 KB
program parcellak;
const maxP = 3001;
type TIndex = integer;
TSize = longint;
TMezo = record
x,y:TIndex;
end;
function genM(x,y:TIndex):TMezo;
var m:TMezo;
begin
m.x:=x;
m.y:=y;
genM:=m;
end;
type TParcella = object
m1,m2:TMezo;
function area:TSize;
procedure init(vm1,vm2:TMezo);
function cont(m:TMezo):boolean;
end;
function TParcella.area:TSize;
begin
area:=(m2.x-m1.x+1)*(m2.y-m1.y+1);
end;
procedure TParcella.init(vm1,vm2:TMezo);
begin
m1:=vm1;
m2:=vm2;
end;
function TParcella.cont(m:TMezo):boolean;
begin
cont:=(m1.x<=m.x)and(m.x<=m2.x)and(m1.y<=m.y)and(m.y<=m2.y)
end;
function genP(m1,m2:TMezo):TParcella;overload;
var p:TParcella;
begin
p.init(m1,m2);
genP:=p;
end;
function genP(x1,y1,x2,y2:TIndex):TParcella;overload;
begin
genP:=genP(genM(x1,y1),genM(x2,y2));
end;
type TParcellaTomb = object
private
t:array[1..maxP] of TParcella;
tn:TIndex;
public
function size:TSize;
procedure add(p:TParcella);
procedure del(ind:TINdex);
function get(ind:Tindex):TParcella;
procedure clear;
end;
function TParcellaTomb.size:TSize;
begin
size:=tn;
end;
procedure TParcellaTomb.add(p:TParcella);
begin
inc(tn);
t[tn]:=p;
end;
procedure TParcellaTomb.del(ind:TINdex);
begin
t[ind]:=t[tn];
dec(tn);
end;
function TParcellaTomb.get(ind:Tindex):TParcella;
begin
get:=t[ind];
end;
procedure TParcellaTomb.clear;
begin
tn:=0;
end;
type TFoldmuves = object
public
procedure foldoszt(m:TMezo);
function maxKeres:TSize;
procedure init(NN,MM:TIndex);
private
tomb:TParcellaTomb;
function find(m:TMezo):TIndex;
end;
procedure TFoldmuves.foldoszt(m:TMezo);
var p:array[0..4] of TParcella;
m1,m2:TMezo;
ind,i:TIndex;
begin
ind:=find(m);
p[0]:=tomb.get(ind);
tomb.del(ind);
m1:=p[0].m1;
m2:=p[0].m2;
p[1]:=genP(m1,genM(m.x-1,m.y-1));
p[2]:=genP(m.x+1,m1.y,m2.x,m.y-1);
p[3]:=genP(m1.x,m.y+1,m.x-1,m2.y);
p[4]:=genP(genM(m.x+1,m.y+1),m2);
for i:=1 to 4 do if p[i].area<>0 then tomb.add(p[i]);
end;
function TFoldmuves.maxkeres:TSize;
var max:TSize;
i:TIndex;
begin
max:=0;
for i:=1 to tomb.size do if (tomb.get(i)).area>max then
max:=(tomb.get(i)).area;
maxkeres:=max;
end;
function TFoldmuves.find(m:TMezo):TIndex;
var i:TIndex;
begin
i:=1;
while (i<=tomb.size)and(not( (tomb.get(i)).cont(m) )) do
inc(i);
find:=i;
end;
procedure TFoldMuves.init(NN,MM:TIndex);
begin
tomb.clear;
tomb.add(genP(1,1,NN,MM));
end;
var fm:TFoldmuves;
NN,MM,KK,x,y,i:TIndex;
begin
readln(NN,MM,KK);
fm.init(NN,MM);
for i:=1 to KK do
begin
readln(x,y);
fm.foldoszt(genM(x,y));
end;
writeln(fm.maxkeres);
end.of.program