[USACO10OCT] Lake Counting S】的更多相关文章

很水的DFS. 为什么放上来主要是为了让自己的博客有一道DFS题解,,, #include<bits/stdc++.h> using namespace std; ][],ans,flag; char sx; void dfs(int x,int y){ ){ flag=; a[x][y]=; dfs(x-,y); dfs(x+,y); dfs(x,y-); dfs(x,y+); dfs(x-,y-); dfs(x+,y-); dfs(x-,y+); dfs(x+,y+); } } int m…
题面 \(\text{Flood Fill}\) 模板题. \(\text{Flood Fill}\) 可以快速求出一个图中连通块的个数. 大概就是遍历每一个点,如果它没有被遍历过且是一个新连通块,那么就将答案 \(+1\),然后从这个点向四周扩展. 主要使用 \(\text{BFS}\) 实现. 由于每个点都只会被遍历 \(1\) 次,因此时间复杂度是 \(O(n \times m)\) . #include <bits/stdc++.h> using namespace std; cons…
题目链接 https://www.luogu.org/problemnew/show/P1596 题目描述 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 eit…
P1596 [USACO10OCT]湖计数Lake Counting 题目描述 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 water ('W'…
来之不易的2017第一发ac http://poj.org/problem?id=2386 Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 31474   Accepted: 15724 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is repr…
Lake Counting Time Limit: 1000MS     Memory Limit: 65536K Total Submissions: 17917     Accepted: 9069 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 <=…
Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28966   Accepted: 14505 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…
1751: [Usaco2005 qua]Lake Counting Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 168  Solved: 130 [Submit][Status] 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…
题目 3385: [Usaco2004 Nov]Lake Counting 数池塘 Time Limit: 1 Sec  Memory Limit: 128 MB Description     农夫约翰的农场可以表示成N×M(1≤N,M≤100)个方格组成的矩形.由于近日的降雨, 在约翰农场上的不同地方形成了池塘.每一个方格或者有积水(’W’)或者没有积水(’.’).农夫约翰打算数出他的农场上共形成了多少池塘.一个池塘是一系列相连的有积水的方格,每一个方格周围的八个方格都被认为是与这个方格相连…
3385: [Usaco2004 Nov]Lake Counting 数池塘 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 22  Solved: 21[Submit][Status][Discuss] Description     农夫约翰的农场可以表示成N×M(1≤N,M≤100)个方格组成的矩形.由于近日的降雨, 在约翰农场上的不同地方形成了池塘.每一个方格或者有积水(’W’)或者没有积水(’.’).农夫约翰打算数出他的农场上共形成了多少池…