POJ-1054-The Troublesome Frog

暴力水 -_-||

#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<vector>
#include<math.h>
#include<stack>
using namespace std;
const int MAX = 5000+10;
const double eps = 1e-10;
const double PI = acos(-1.0);
bool maps[MAX][MAX];
int c, r, n, maxx;
struct node
{
    int x, y;
} lxt[MAX];
bool cmp(node a, node b)
{
    if(a.x!=b.x)return a.x<b.x;
    return a.y<b.y;
}
bool check(int x, int y)
{
    if(x>=1&&x<=r&&y>=1&&y<=c)return 1;
    return 0;
}
int solve(int x, int y, int dx, int dy)
{
    int ans = 2;
    while(1)
    {
        x+=dx;
        y+=dy;
        if(!check(x, y))break;
        if(maps[x][y])ans++;
        else return 0;
    }
    return ans;
}
int main()
{
    scanf("%d%d%d", &r, &c, &n);
    memset(maps, 0, sizeof(maps));
    for(int i =0; i<n; ++i)
    {
        scanf("%d%d", &lxt[i].x, &lxt[i].y);
        maps[lxt[i].x][lxt[i].y] = 1;
    }
    sort(lxt, lxt+n, cmp);
    maxx = 2;
    for(int i =0; i<n-1; ++i)
    {
        for(int j = i+1; j<n; ++j)
        {
            int dx = lxt[j].x-lxt[i].x;
            int dy = lxt[j].y-lxt[i].y;
            if(check(lxt[i].x-dx, lxt[i].y-dy))continue;
            maxx = max(maxx, solve(lxt[j].x, lxt[j].y, dx, dy));
        }
    }
    if(maxx==2)cout<<0<<endl;
    else cout<<maxx<<endl;
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值