1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
| /*
ID:du331691
PROG:rectbarn
LANG:C++
*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
template<typename T>
void read(T& w)
{
char r;
for(r=getchar();r<48||r>57;r=getchar());
for(w=0;r>=48&&r<=57;r=getchar())w=w*10+r-48;
}
template<typename T>
T Min(const T& a,const T& b){return a<b?a:b;}
template<typename T>
T Max(const T& a,const T& b){return a>b?a:b;}
const int maxn=3003;
const int maxp=30003;
int n,m,p;
bool tree[maxn][maxn];
int height[2][maxn];
int treel[2][maxn],treer[2][maxn];
int Left[2][maxn],Right[2][maxn];
void input()
{
read(n),read(m),read(p);
int x,y;
for(int i=1;i<=p;++i)
{
read(x),read(y);
tree[x][y]=true;
}
}
int ans=0;
void dp()
{
for(int j=1;j<=m;++j)
tree[0][j]=tree[n+1][j]=true;
for(int i=2;i<=n-1;++i)
{
tree[i][0]=tree[i][m+1]=true;
}
for(int i=1;i<=n;++i)
{
int now=i&1,lst=i&1^1;
for(int j=1,last=0;j<=m;++j)
{
if(tree[i][j])
last=j;
treel[now][j]=last;
}
for(int j=m,last=m+1;j>=1;--j)
{
if(tree[i][j])
last=j;
treer[now][j]=last;
}
for(int j=1;j<=m;++j)
{
if(tree[i-1][j])
{
height[now][j]=1;
Left[now][j]=treel[now][j];
Right[now][j]=treer[now][j];
}
else
{
height[now][j]=height[lst][j]+1;
Left[now][j]=Max(treel[now][j],Left[lst][j]);
Right[now][j]=Min(treer[now][j],Right[lst][j]);
}
if(!tree[i][j])
{
int tans=(Right[now][j]-Left[now][j]-1)*height[now][j];
if(tans>ans)
ans=tans;
}
}
}
}
int main()
{
freopen("rectbarn.in","r",stdin);
freopen("rectbarn.out","w",stdout);
input();
dp();
printf("%d\n",ans);
return 0;
}
|