POJ3620Avoid The Lakes

题意:

给一些坐标,求最大的连通块

爆搜不解释

/*************************************************************************
    > File Name: C.cpp
    > Author: huhao
    > Mail: 826538400@qq.com 
    > Created Time: 2017/5/13 14:36:07
 ************************************************************************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
#define inf 0x3f3f3f3f
#define eps 1e-8
#define rt return
#define gc getchar()
#define ll long long
#define fr(i,a,b) for(int i=a,_end_=b;i<=_end_;i++)
#define fd(i,a,b) for(int i=a,_end_=b;i>=_end_;i--)
void SWAP(int a,int b)
{
    a^=b^=a^=b;
}
int read()
{
    int r=1,t=0;
    char c=gc;
    while(c<'0'||c>'9')
    {
        if(c=='-')
            r=-1;
        else
            r=1;
        c=gc;
    }
    while(c>='0'&&c<='9')
    {
        t=(t<<1)+(t<<3)+(c^48);
        c=gc;
    }
    rt r*t;
}
char readchar(int x,int y)
{
    char c=gc;
    while(c<x||c>y)
        c=gc;
    rt c;
}
double log(double x,double y)
{
    rt log10(x)/log10(y);
}
int gcd(int x,int y)
{
    rt y?gcd(y,x%y):x;
}
int lcm(int x,int y)
{
    rt x*y/gcd(x,y);
}
int f[210][210],p[210][210],n,m,ans;
int dfs(int x,int y)
{
    if(!f[x][y]||p[x][y])rt 0;
    p[x][y]=1;
    rt 1+dfs(x+1,y)+dfs(x-1,y)+dfs(x,y+1)+dfs(x,y-1);
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("", "r", stdin);
    freopen("", "w", stdout);
#endif
    n=read();
    m=read();
    fr(i,1,read())
        f[read()][read()]=1;
    fr(i,1,n)
        fr(j,1,m)
            if(!p[i][j]&&f[i][j])
                ans=max(ans,dfs(i,j));
    printf("%d\n",ans);
    rt 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值