POJ2386 Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 25366 Accepted: 12778 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 (1 <=…
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 25322 Accepted: 12759 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 (1 <= N <= 10…
湖计数描述由于最近的降雨,水汇集在不同的地方,在农民约翰的领域,这是代表一个长方形的N×M(1μ= 100:1 = M = 100)平方.每一方都包含水(’w')或干燥的土地(“.”).农民约翰想弄清楚在他的田里已经形成了多少个池塘.一个池塘是一个连接的正方形与水在他们,其中一个正方形被认为是相邻的所有八个它的邻居.给定一个农民约翰的领域的图表,确定他有多少个池塘.输入行1:两个空格分隔的整数:N和M*线2 .. N + 1:M字符每行代表一行的农民约翰的领域.每个字符是“W”或“.”.字符之间…
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 34735 Accepted: 17246 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 (1 <= N <= 10…
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 49414 Accepted: 24273 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 (1 <= N <= 10…
题目链接:http://poj.org/problem?id=2386 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 (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either wa…
本题是一道连通块的入门题,用来练手,后续还会更新连通块的题目. 本题大意:一个n * m 的陆地上面有很多水洼,让你统计水洼的个数并输出. 本题思路:按照顺序遍历陆地,如果发现水洼就将它的八连块都进行探索,发现水洼就继续探索,直到一片大水洼都被探索完,就继续进行其他搜索,DFS. 代码: #include <cstdio> using namespace std; + ; char field[maxn][maxn]; int n, m, ans; void dfs(int u, int v)…