[USACO10OCT]Lake Counting(DFS)
很水的DFS.
为什么放上来主要是为了让自己的博客有一道DFS题解,,,
#include<bits/stdc++.h>
using namespace std;
int a[][],ans,flag;
char sx;
void dfs(int x,int y){
if(a[x][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 main(){
int n,m;
ans=;
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
cin>>sx;
if(sx=='.'){
a[i][j]=;
}if(sx=='W'){
a[i][j]=;
}
}
}
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
flag=;
dfs(i,j);
if(flag==){
ans++;
}
}
}
printf("%d",ans);
return ;
}
[USACO10OCT]Lake Counting(DFS)的更多相关文章
- POJ:2386 Lake Counting(dfs)
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 40370 Accepted: 20015 D ...
- Poj2386 Lake Counting (DFS)
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 49414 Accepted: 24273 D ...
- POJ 2386——Lake Counting(DFS)
链接:http://poj.org/problem?id=2386 题解 #include<cstdio> #include<stack> using namespace st ...
- Lake Counting(dfs)
Description Due to recent rains, water has pooled in various places in Farmer John's field, which is ...
- POJ_2386 Lake Counting (dfs 错了一个负号找了一上午)
来之不易的2017第一发ac http://poj.org/problem?id=2386 Lake Counting Time Limit: 1000MS Memory Limit: 65536 ...
- 【POJ - 2386】Lake Counting (dfs+染色)
-->Lake Counting 直接上中文了 Descriptions: 由于近日阴雨连天,约翰的农场中中积水汇聚成一个个不同的池塘,农场可以用 N x M (1 <= N <= ...
- 题解报告:poj 2386 Lake Counting(dfs求最大连通块的个数)
Description Due to recent rains, water has pooled in various places in Farmer John's field, which is ...
- LeetCode Subsets II (DFS)
题意: 给一个集合,有n个可能相同的元素,求出所有的子集(包括空集,但是不能重复). 思路: 看这个就差不多了.LEETCODE SUBSETS (DFS) class Solution { publ ...
- LeetCode Subsets (DFS)
题意: 给一个集合,有n个互不相同的元素,求出所有的子集(包括空集,但是不能重复). 思路: DFS方法:由于集合中的元素是不可能出现相同的,所以不用解决相同的元素而导致重复统计. class Sol ...
随机推荐
- 使用virtualenv使得Python2和Python3并存
1:下载python3源码并安装 wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz .tgz cd Python-.tgz . ...
- ZOJ 3956 Course Selection System [01背包]
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3956 题意:就是给你Hi,Ci的值,问怎么取使得下面那个式子的值最大: 理 ...
- 机房收费系统之【只允许一个MDI窗体 错误:426】 标签: vb 2014-08-15 10:36 1149人阅读 评论(23)
机房收费系统的主窗体是MDI窗体,为了在这个窗体上添加控件,所以我们在窗体上添加了picture控件,在MDI窗体中,子窗体实际上位于MDIClient里,即子窗体的父窗体就是MDIClient,而放 ...
- LeetCode108 Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. (M ...
- HZOJ Weed
作者的题解: 如果一段操作被执行,会对整个栈有什么影响呢? 把栈弹出若干个数后再插入若干个数. 线段树: 每个点纪录三个值:执行完这段操作后会删多少个,再插多少个,插的和一共是多少. 合并值时再用一个 ...
- 2018-8-10-win10-uwp-如何在DataTemplate绑定方法
title author date CreateTime categories win10 uwp 如何在DataTemplate绑定方法 lindexi 2018-08-10 19:16:50 +0 ...
- 解决pip is configured with locations that require TLS/SSL问题
python3.7安装, 解决pip is configured with locations that require TLS/SSL问题1.安装相关依赖 yum install gcc libff ...
- selenium webdriver学习(八)------------如何操作select下拉框(转)
selenium webdriver学习(八)------------如何操作select下拉框 博客分类: Selenium-webdriver 下面我们来看一下selenium webdriv ...
- oracle函数 floor(x)
[功能]返回小于等于x的最大整数值 [参数]x,数字型表达式 [返回]数字 [示例] select floor(3.1),floor(2.8+1.3),floor(0) from dual; 返回4, ...
- C++高精度加减乘除模板
其中高精度乘法通过了POJ2389,其他没有测过,不过应该是没有问题的. 其中高精度除法返回一对string,分别表示商和余数. 代码: #include <bits/stdc++.h> ...