题意:判断连通块大小 水题

//By SiriusRen
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m,a[1111][88],xx[]={1,-1,0,0},yy[]={0,0,1,-1},vis[1111][88],ans,temp;
void dfs(int x,int y){
for(int i=0;i<4;i++){
if(!vis[x+xx[i]][y+yy[i]]&&a[x+xx[i]][y+yy[i]]=='*')
temp++,vis[x+xx[i]][y+yy[i]]=1,dfs(x+xx[i],y+yy[i]);
}
}
int main(){
scanf("%d%d",&m,&n);
for(int i=1;i<=n;i++)
for(int j=0;j<=m;j++)
a[i][j]=getchar();
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(!vis[i][j]&&a[i][j]=='*'){
vis[i][j]=1;
temp=1;
dfs(i,j);
ans=max(ans,temp);
}
printf("%d\n",ans);
}

POJ 3051 DFS的更多相关文章

  1. POJ 1321 DFS

    题意:POJ少见的中文题,福利啊. 思路: 一开始也没有思路呃呃呃 . 裸搜,连样例都过不去...参照了网上的题解:一行一行DFS 茅塞顿开啊. #include <cstdio> #in ...

  2. POJ 1979 dfs和bfs两种解法

      fengyun@fengyun-server:~/learn/acm/poj$ cat 1979.cpp #include<cstdio> #include<iostream&g ...

  3. poj 1190 DFS 不等式放缩进行剪枝

    F - (例题)不等式放缩 Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submi ...

  4. poj 1562 dfs

    http://poj.org/problem?id=1562 #include<iostream> using namespace std; ,m=,sum=; ][]; ][]={-,, ...

  5. POJ 1979 DFS

    题目链接:http://poj.org/problem?id=1979 #include<cstring> #include<iostream> using namespace ...

  6. poj 1088 (dfs+记忆化) 滑雪

    题目;http://poj.org/problem?id=1088 感觉对深搜还不太熟练,所以练习一下,类似于连连看的那题,注意的是所求的是最大达长度,并不是从最大的或者最小的点出发得到的就是最长的路 ...

  7. Oil Deposits(poj 1526 DFS入门题)

    http://poj.org/problem?id=1562                                                                       ...

  8. POJ 3414 dfs 回溯

    题目链接:http://poj.org/problem?id=3414 题意:三个值A, B, C, A和B是两个杯子的容量,问最短操作数使A或者B里的水量是C.有三种操作. 思路:dfs.暴力 很简 ...

  9. poj 2531(dfs)

    题目链接:http://poj.org/problem?id=2531 思路:由于N才20,可以dfs爆搞,枚举所有的情况,复杂度为2^(n). #include<iostream> #i ...

随机推荐

  1. IE11 mobile 的 UA(User-Agent)

    如果您在 IE11 mobile 上获得的 UA(User-Agent) 是 Mozilla/5.0 (Mobile; Linux; Android 4.2; Microsoft Build/Virt ...

  2. 使用google API之前需要對input 做什麼 安全性的處理?

    我正要使用node.js 和 google map api做一个小应用,Google MAP API的使用URL如下: https://maps.googleapis.com/maps/api/pla ...

  3. [APIO2010]巡逻(树的直径)

    [APIO2010]巡逻 题目描述 在一个地区中有 n 个村庄,编号为 1, 2, ..., n.有 n – 1 条道路连接着这些村 庄,每条道路刚好连接两个村庄,从任何一个村庄,都可以通过这些道路到 ...

  4. .ashx 实现自动路由和参数填充

    在Mvc中访问控制器,参数填充和路由控制都非常方便,但之前项目用的是webFrom,和js交互的ashx页面,路由非常麻烦要根据传进来关键字来做switch,参数填充更坑,要一个一个去form中取出来 ...

  5. 【cdoj 1544】当咸鱼也要按照基本法

    [题目链接]:http://acm.uestc.edu.cn/#/problem/show/1544 [题意] [题解] 容斥原理题; 1..(2^m)-1枚举 设k为其二进制形式中1的个数; k为奇 ...

  6. HDUOJ Let the Balloon Rise 1004

     /* Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  7. POJ 1986 裸的LCA

    思路:搞了一发链剖 //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> ...

  8. win7防火墙里开启端口的图文教程

    转载于:http://www.cnblogs.com/vipsoft/archive/2012/05/02/2478847.html 开启端口:打开“控制面板”中的“Windows防火墙”,点击左侧的 ...

  9. jquery.base64.js

    (function($) { $.base64 = function(options) { var defaults = { data:"", type:0, unicode:tr ...

  10. PHP高手进阶-LAMPer技能树