poj 3620 Avoid The Lakes(广搜,简单)
找最大的一片湖的面积,4便有1边相连算相连,4角不算。
runtime error 有一种可能是 数组开的太小,越界了
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
#define MAXN 110
int map[MAXN][MAXN];
int n,m,sum,a[MAXN*MAXN],b[MAXN*MAXN];//runtime error 原来是这里小了
int xx[]={,,,-};
int yy[]={,-,,};
struct tt
{
int x,y;
}; int bfs()
{
int ans,maxx=;
tt front,rear,temp;
queue<tt>q;
while(!q.empty())
q.pop();
for(int i=;i<sum;i++)
{
if(map[a[i]][b[i]]==)
{
front.x=a[i];front.y=b[i];
q.push(front);
map[a[i]][b[i]]=;
ans=;
while(!q.empty())
{
temp=q.front();
q.pop();
for(int j=;j<;j++)
{
rear.x=temp.x+xx[j];
rear.y=temp.y+yy[j];
if(rear.x>&&rear.y>&&rear.x<=n&&rear.y<=m&&map[rear.x][rear.y]==)
{
q.push(rear);
map[rear.x][rear.y]=;
ans++;
maxx=maxx>ans? maxx:ans;
}
}
}
}
}
return maxx;
} int main()
{
int i;
while(scanf("%d%d%d",&n,&m,&sum)!=EOF)
{
memset(map,,sizeof(map));
for(i=;i<sum;i++)
{
scanf("%d%d",&a[i],&b[i]);
map[a[i]][b[i]]=;
}
printf("%d\n",bfs());
} return ;
}
poj 3620 Avoid The Lakes(广搜,简单)的更多相关文章
- poj 3620 Avoid The Lakes【简单dfs】
Avoid The Lakes Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6795 Accepted: 3622 D ...
- [深度优先搜索] POJ 3620 Avoid The Lakes
Avoid The Lakes Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8173 Accepted: 4270 D ...
- POJ 3620 Avoid The Lakes【DFS找联通块】
Avoid The Lakes Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6826 Accepted: 3637 D ...
- POJ 3620 Avoid The Lakes
http://poj.org/problem?id=3620 DFS 从任意一个lake出发 重置联通的lake 并且记录 更新ans #include <iostream> #inclu ...
- POJ 3620 Avoid The Lakes(dfs算法)
题意:给出一个农田的图,n行m列,再给出k个被淹没的坐标( i , j ).求出其中相连的被淹没的农田的最大范围. 思路:dfs算法 代码: #include<iostream> #inc ...
- POJ 3620 Avoid The Lakes (求连接最长的线)(DFS)
Description Farmer John's farm was flooded in the most recent storm, a fact only aggravated by the i ...
- POJ 2251 Dungeon Master(广搜,三维,简单)
题目 简单的3d广搜,做法类似与 hdu 的 胜利大逃亡 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<str ...
- poj 3984:迷宫问题(广搜,入门题)
迷宫问题 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7635 Accepted: 4474 Description ...
- poj 3026 Borg Maze 最小生成树 + 广搜
点击打开链接 Borg Maze Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7097 Accepted: 2389 ...
随机推荐
- cocos2d-x 节点操作 -->J2ME
cocos2d-x 的节点操作涉及到以下几点 1. 节点之间的关系 2. 节点的添加操作 3. 节点的删除操作 4. ...
- 2015.1写留言板的时用的 知识点和函数 --->总结
一:时间函数和uniqid() 1:uniqid():生成唯一的id, 无参数返回的字符串的长度为13,有参数为23 2:时间和时间戳相互转换的php函数 ①:time() 返回当前unix的时间戳 ...
- nginx配置:支持phpfastcgi,nginx和php-cgi通信,部分nginx常量解释
支持phpfastcgi的配置如下: server { listen 8000; server_name localhost; root F:/home/projects/test; i ...
- Spark菜鸟学习营Day6 分布式代码运行调试
Spark菜鸟学习营Day6 分布式代码运行调试 作为代码调试,一般会分成两个部分 语法调试,也就是确定能够运行 结果调试,也就是确定程序逻辑的正确 其实这个都离不开运行,所以我们说一下如何让开发的S ...
- Linux&UNIX上卸载GoldenGate的方法
1. Log on to the database server (as oracle) where the GoldenGate software is installed. [root@oracl ...
- 【转载】Powershell获取世纪互联Office365中所有用户的OWA时区
get-mailbox -resultsize unlimited | Get-MailboxRegionalConfiguration | select Identity,TimeZone | wh ...
- MySQL 5.7.9的多源复制
什么是多源复制? 首先,我们需要清楚 multi-master 与multi-source 复制不是一样的. Multi-Master 复制通常是环形复制,你可以在任意主机上将数据复制给其他主机. M ...
- [ERROR] Failed to open log
版本:5.5.14 性能测试部-测试环境数据库 1.在性能测试过程中大量的日志,测试人员直接使用 rm -rf 删除所有 2.重启数据库时,出现报错,导致数据库无法启动,查看报错日志,报错信息如下: ...
- 试图使用未在此报表服务器中注册或此版 Reporting Services 不支持的数据扩展插件“Devart.Data.PostgreSql”
数据源用的是Postgresql 我在Deploy Report的时候出现这条ErrorMessage Error 2 试图使用未在此报表服务器中注册或此版 Reporting Services 不支 ...
- XenServer安装虚拟机---先扩容存放ISO镜像文件
我们都知道xenserver安装后,不管你的盘有多大,只有4G的空间. 故操作是:新建LV卷,可自定义大小 1.vgdisplay #先查看剩余空间 [root@XenServer /]# vgdis ...