hdu 1241 Oil Deposits】的更多相关文章

HDU 1241 题目大意:给定一块油田,求其连通块的数目.上下左右斜对角相邻的@属于同一个连通块. 解题思路:对每一个@进行dfs遍历并标记访问状态,一次dfs可以访问一个连通块,最后统计数量. /* HDU 1241 Oil Deposits --- 入门DFS */ #include <cstdio> int m, n; //n行m列 ][]; /* 将和i,j同处于一个连通块的字符标记出来 */ void dfs(int i, int j){ || j < || i >=…
HDU 1241  Oil Deposits L -DFS Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u   Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large r…
HDU 1241 Oil Deposits(石油储藏) 00 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)   Problem Description - 题目描述 The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large…
HDOJ(HDU).1241 Oil Deposits(DFS) [从零开始DFS(5)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DFS HDOJ.1010 Tempter of the Bone [从零开始DFS(1)] -DFS四向搜索/奇偶剪枝 HDOJ(HDU).1015 Safecracker [从零开始DFS(2)] -DFS四向搜索变种 HDOJ(HDU).1016 Prime Ring Problem (…
题目传送门 /* DFS:油田问题,一道经典的DFS求连通块.当初的难题,现在看上去不过如此啊 */ /************************************************ Author :Running_Time Created Time :2015-8-4 10:11:11 File Name :HDOJ_1241.cpp ************************************************/ #include <cstdio> #i…
Oil Deposits Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 4   Accepted Submission(s) : 3 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description The GeoSurvComp geologic s…
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8274 Accepted Submission(s): 4860 Problem Description The GeoSurvComp geologic survey company is responsible for detecting underground…
Oil Deposits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15533    Accepted Submission(s): 8911 Problem Description The GeoSurvComp geologic survey company is responsible for detecting underg…
Problem Description 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 pl…
题目:   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 a…
题目链接:Oil Deposits 解析:问有多少个"@"块.当中每一个块内的各个"@"至少通过八个方向之中的一个相邻. 直接从"@"的地方開始向相邻八个方向搜索,每搜到一个格子.就将它替换成".",一次搜索就会搜索完一个块,记录搜索的次数为答案. AC代码: #include <cstdio> #include <cstring> #include <queue> using namesp…
解题思路:第一道DFS的题目--- 参看了紫书和网上的题解-- 在找到一块油田@的时候,往它的八个方向找,直到在能找到的范围内没有油田结束这次搜索 可以模拟一次DFS,比如说样例 在i=0,j=1时,发现第一块油田,对它DFS,这样经过一次DFS,所有的油田都被找出来了,被记0 Oil Deposits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submiss…
Oil Deposits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 45017    Accepted Submission(s): 25972 Problem Description The GeoSurvComp geologic survey company is responsible for detecting under…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1241 题意: 求某块平面上,连通块的数量.一个油田格子若周围八个方向也有一个油田格子,则认为两者相连通. AC代码: #include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; ; ]={,,,-,,,-,-}; ]={,,-,,,-,,-}; int m,n; char mp[maxn][maxn];…
http://acm.hdu.edu.cn/showproblem.php?pid=1241 对每个还未访问的点bfs,到达的点都标为一块,最后统计有多少块即可 #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxn=101; const int inf=0x3fffffff; char maz[maxn][maxn]; int id[maxn][…
嗯... 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1241 很经典的一道dfs,但是注意每次查到一个@之后,都要把它变成“ * ”,然后继续dfs,这样在dfs过程中一些@变成了“ * ”.这样也不需要flag数组,当继续遍历图的时候,再有@就是独立的,ans++.最后ans里边便是答案... AC代码: #include<cstdio> #include<iostream> #include<cstring> us…
链接 : Here! 思路 : 搜索判断连通块个数, 所以 $DFS$ 或则 $BFS$ 都行喽...., 首先记录一下整个地图中所有$Oil$的个数, 然后遍历整个地图, 从油田开始搜索它所能连通多少块其他油田, 只需要把它所连通的油田个数减去, 就ok了 /************************************************************************* > File Name: E.cpp > Author: > Mail: >…
#include<cstdio> #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<vector> #include<queue> #include<iterator> #include<vector> using namespace std; ][]={{-,-},{-,},{-,…
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; ][]; ][]={, , , , -, , , -, , , , -, -, , -, -}; int n, m; int ans; bool judge(int x, int y){ || x>n || y< || y>m) return false…
解题思路: 1. 遍历扫描二维数组,遇到‘@’,结果ans++; 2. 将当前 i,j 位置置为‘*’,将当前‘@’的 i,j 传人到DFS函数中,开始遍历八个方向的字符 如果碰到 '@' 则先将当前置为‘*’,然后再次递归传递,直到超出界限或者扫描不到‘@’,结束递归 3. DFS()的作用是将i,j为开始周围连续的“@”全部改为‘*’ 4. 最后输出 ans 即可: Ac code : #include<bits/stdc++.h> using namespace std; ][]; st…
最水的一道石油竟然改了一个小时,好菜好菜. x<=r  y<=c  x<=r  y<=c  x<=r  y<=c  x<=r y<=c #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; ][]={,, ,-, ,, -,, ,, ,-, -,, -,-}; int r,c; ][]; int ans; void dfs…
题目大意:给你一个m*n的矩阵,里面有两种符号,一种是 @ 表示这个位置有油田,另一种是 * 表示这个位置没有油田,现在规定相邻的任意块油田只算一块油田,这里的相邻包括上下左右以及斜的的四个方向相邻的位置.要你求出一共有多少块油田. 解题报告:用dfs,我的做法是首先在输入的时候将每个有油田的位置标记为1,否则标记为0,然后枚举每一个点,如果这个点有油田,则以这个点为起点,像周围的八个方向搜索,搜到了相邻的点就标记为2,当然这里也可以标记为0,只要是将已经搜过的点标记掉就是了,当dfs退出到ma…
题目链接 https://cn.vjudge.net/contest/65959#problem/L 题意 @表示油田 如果 @@是连在一起的 可以八个方向相连 那么它们就是 一块油田 要找出 一共有几块油田 思路 可以先遍历 一遍地图 遇到 @ 就更新答案 + 1 然后DFS 把与它相连 和与它相连的 相连的 油田 都变成 * 就可以了 AC代码 #include <cstdio> #include <cstring> #include <ctype.h> #incl…
八方向   深搜 #include <iostream> #include<cstdio> #include<cstdlib> #include<algorithm> using namespace std; ][]; ]= {-,-,-,, , ,,}; ]= {-, , ,-,,-,,}; //8个方向 void dfs(int x, int y) { maps[x][y] = '*'; //变为*,相当于走过 ; i < ; i++) { int…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8976    Accepted Submission(s): 5245 Problem Description The GeoSurvComp geologic survey company is responsible for detecting underground oil dep…
Oil Deposits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16542    Accepted Submission(s): 9500 Problem Description The GeoSurvComp geologic survey company is responsible for detecting underg…
Oil Deposits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11842    Accepted Submission(s): 6873 Problem Description The GeoSurvComp geologic survey company is responsible for detecting under…
题目: 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 ana…
Oil Deposits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 43487    Accepted Submission(s): 25275 Problem Description The GeoSurvComp geologic survey company is responsible for detecting under…
Description 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…