//poj 1054
//sep9
#include <iostream>
#include <algorithm>
using namespace std;
struct NODE
{
int x,y;
}p[5012];
bool vis[5012][5012];
int n,r,c;
int cmp(NODE a,NODE b)
{
return a.y!=b.y?a.y<b.y:a.x<b.x;
}
int main()
{
scanf("%d%d%d",&r,&c,&n);
memset(vis,false,sizeof(vis));
for(int i=0;i<n;++i){
scanf("%d%d",&p[i].x,&p[i].y);
vis[p[i].x][p[i].y]=true;
}
sort(p,p+n,cmp);
int maxx=0;
for(int i=0;i<n;++i)
for(int j=i+1;j<n;++j){
int dx=p[j].x-p[i].x;
int dy=p[j].y-p[i].y;
if(p[i].x-dx>0&&p[i].x-dx<=r&&p[i].y-dy>0&&p[i].y-dy<=c)
continue;
int tx=p[j].x+dx;
int ty=p[j].y+dy;
int cnt=0;
while(tx>0&&tx<=r&&ty>0&&ty<=c){
if(vis[tx][ty]) ++cnt,tx+=dx,ty+=dy;
else{
cnt=0;
break;
}
}
maxx=max(maxx,cnt);
}
if(maxx) printf("%d",maxx+2);
else printf("0");
return 0;
}
poj 1054 The Troublesome Frog 枚举
最新推荐文章于 2022-04-22 21:41:26 发布