POJ 3620 Avoid The Lakes【DFS找联通块】
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 6826 | Accepted: 3637 |
Description
Farmer John's farm was flooded in the most recent storm, a fact only aggravated by the information that his cows are deathly afraid of water. His insurance agency will only repay him, however, an amount depending on the size of the largest "lake" on his farm.
The farm is represented as a rectangular grid with N (1 ≤ N ≤ 100) rows andM (1 ≤M ≤ 100) columns. Each cell in the grid is either dry or submerged, and exactlyK (1 ≤K ≤N × M) of the cells are submerged. As one would expect, a lake has a central cell to which other cells connect by sharing a long edge (not a corner). Any cell that shares a long edge with the central cell or shares a long edge with any connected cell becomes a connected cell and is part of the lake.
Input
* Line 1: Three space-separated integers: N, M, and K
* Lines 2..K+1: Line i+1 describes one submerged location with two space separated integers that are its row and column:R andC
Output
* Line 1: The number of cells that the largest lake contains.
Sample Input
3 4 5
3 2
2 2
3 1
2 3
1 1
问题描述
农民约翰的农场被最近的一场暴风雨(storm)所淹没(flooded),事实却依旧恶化(aggravated),由于他的牛怕水,已经快死了。但是,他的保险公司(insurance agency)将会根据他农场中最大水池的大小来赔偿。
他的农场可视作一个N行(rows)M列(columns)的矩形(rectangular)网格(grid)。每格(cell)不是干的就是在水里的(submerged),准确来说,有K(1 ≤K ≤N ×M)格是湿的,
输入
第一行:三个分开的整数,N,M和K
第二行...第K+1行:第i+1行为湿地坐标,横坐标R和纵坐标C
输出:
第一行:最大湖泊的格子数
POJ 3620 Avoid The Lakes【DFS找联通块】的更多相关文章
- 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算法)
题意:给出一个农田的图,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 3620 Avoid The Lakes
http://poj.org/problem?id=3620 DFS 从任意一个lake出发 重置联通的lake 并且记录 更新ans #include <iostream> #inclu ...
- poj 3620 Avoid The Lakes(广搜,简单)
题目 找最大的一片湖的面积,4便有1边相连算相连,4角不算. runtime error 有一种可能是 数组开的太小,越界了 #define _CRT_SECURE_NO_WARNINGS #incl ...
- 用dfs求联通块(UVa572)
一.题目 输入一个m行n列的字符矩阵,统计字符“@”组成多少个八连块.如果两个字符所在的格子相邻(横.竖.或者对角线方向),就说它们属于同一个八连块. 二.解题思路 和前面的二叉树遍历类似,图也有DF ...
- 利用DFS求联通块个数
/*572 - Oil Deposits ---DFS求联通块个数:从每个@出发遍历它周围的@.每次访问一个格子就给它一个联通编号,在访问之前,先检查他是否 ---已有编号,从而避免了一个格子重复访问 ...
- 用dfs遍历联通块(优化)
一.题目(CF 598D) 输入一个n x m的字符矩阵,求从某个空点出发,能碰到多少面墙壁,总共询问k次.(3 ≤m,n ≤1000,1 ≤ k ≤ min(nm,100 000)) 二.解题思路 ...
随机推荐
- Object Pascal中文手册 经典教程
Object Pascal 参考手册 (Ver 0.1)ezdelphi@hotmail.com OverviewOverview(概述)Using object pascal(使用 object p ...
- USACO Section2.1 Healthy Holsteins 解题报告 【icedream61】
holstein解题报告 --------------------------------------------------------------------------------------- ...
- 程序员必备PC维修法(软件篇)
学会使用专业软件检测与修复电脑硬件故障问题也是程序员的一种软技能. windows篇 情景:如何获取电脑硬件的真实信息.(如何检验选购回来的硬件是否正品) 自检:使用AIDA64软件检查电脑硬件,能详 ...
- Linux认知之旅【02 装个软件玩玩】!
〇.命令行终端熟悉了吗? 1.没有仔细研究上一篇文章? 拿上看看这几个命令:ls.cd.cp.mv.rm.mkdir.touch.cat.less.恩,暂时这些够用了! 什么?你连虚拟机也没装! 感谢 ...
- FlexGrid布局
FlexGrid布局: Grid布局时网格大小是固定的,如果想网格大小不同的界面可以使用FlexGrid布局.FlexGrid是更加灵活的Grid布局.FlexGrid布局类是wx.FlexGridS ...
- PHP如何实现第三方分享
<!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...
- php设计模式 工厂模式和单例
1.单例模式//让该类在外界无法造对象//让外界可以造一个对象,做一个静态方法返回对象//在类里面通过让静态变量控制返回对象只能是一个. class cat{ public $name; privat ...
- CSS 3中细线边框如何实现?
在app应用开发中,我们常常都需要用到css3来设置应用的样式.由于app都是在移动设备上进行展示,所以边框描边的线一般都小于1px,而以往我们使用的都是1px及以上的.那么问题来了,对于小于1px的 ...
- easyui中datagrid空数据集不刷新的解决方式
datagrid空间可以异步请求json数据,并将新数据覆盖原有数据,重绘数据表. 但是当回来空数据集的时候,js会产生这样一条错误: TypeError: rows is null for(var ...
- bzoj2441 [中山市选2011]小W的问题(debug中)
2441: [中山市选2011]小W的问题 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 487 Solved: 186[Submit][Statu ...