ACM:油田(Oil Deposits,UVa 572)】的更多相关文章

/* Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 37990 Accepted Submission(s): 22039 Problem Description The GeoSurvComp geologic survey company is responsible for detecting undergr…
The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. It then analyze…
题目描述: 原题:https://vjudge.net/problem/UVA-572 题目思路: 1.图的DFS遍历 2.二重循环找到相邻的八个格子 AC代码: #include <iostream> #include <cstring> using namespace std; ; char pic[maxn][maxn] ; int tag[maxn][maxn] ; //已经遍历过的标志 int m, n; void dfs(int r,int c,int cnt) { |…
题意:给你一个地图,求联通块的数量. 题解: for(所有还未标记的‘@’点) 边dfs边在vis数组标记id,直到不能继续dfs. 输出id及可: ac代码: #define _CRT_SECURE_NO_WARNINGS #include "stdio.h" #include<stdio.h> #include<algorithm> #include<string> #include<vector> #include<list&…
[本博文非博主原创,均摘自:刘汝佳<算法竞赛入门经典>(第2版) 6.4 图] [程序代码根据书中思路,非独立实现] 例题6-12 油田(Oil Deposits,UVa572) 输入一个m行n列的字符矩阵,统计字符“@”组成多少个八连块.如果两个字符“@”所在的格子相邻(横.纵或者对角线方向),就说它们属于一个八连块.例如,下图中有两个八连块. 一.分析 1.1 整体思路 图也有DFS和BFS遍历.由于DFS更容易编写,一般用DFS查找连通块:从每个"@"格子出发,递归遍…
油田 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=84562#problem/L 题意: 输入一个m行n列的字符矩形,统计字符“@”组成多少个八连块.如果两个字符“@”所在的格子相邻(横,竖或者对角线方向), 就说题目属于同一个八连块. 样例: Sample Input 1 1 * 3 5 *@*@* **@** *@*@* 1 8 @@****@* 5 5 ****@ *@@*@ *@**@ @@@*@ @@**@ 0…
这是我在洛谷上的第一篇题解!!!!!!!! 这个其实很简单的 我是一只卡在了结束条件这里所以一直听取WA声一片,详细解释代码里见 #include<iostream> #include<cstdio> #include<cstring> #include<iomanip> #include<algorithm> using namespace std; ][];//霸气的开始潇洒自信 ; ,m=-; void ac(int x,int y) {…
UVA 572     DFS(floodfill)  用DFS求连通块 Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M…
UVA 572 -- Oil Deposits(DFS求连通块) 图也有DFS和BFS遍历,由于DFS更好写,所以一般用DFS寻找连通块. 下述代码用一个二重循环来找到当前格子的相邻8个格子,也可用常量数组或者写8条DFS调用. 下述算法是:种子填充(floodfill) 两种连通区域 四连通区域:从区域内一点出发,可通过上.下.左.右四个方向的移动组合,在不越出区域的前提下,能到达区域内的任意像素 八连通区域:从区域内每一像素出发,可通过八个方向,即上.下.左.右.左上.右上.左下.右下移动的…
Oil Deposits  The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. I…