poj 3051 Satellite Photographs 基础DFS
来源:互联网 发布:json怎么解析 编辑:程序博客网 时间:2024/05/16 00:25
#include<iostream>using namespace std;char map[1005][83],visited[1005][83];int w,h,ans;int dirx[4] = {1,-1,0,0};int diry[4] = {0,0,1,-1};bool judge(int a,int b){if(a >= 0&&a < h&&b >= 0&&b < w)return true;return false;}void dfs(int x,int y){ans++; //从满足条件的点向其他点扩展visited[x][y] = 1;for(int k = 0;k < 4;k++){int nextx = x + dirx[k];int nexty = y + diry[k];if(judge(nextx,nexty)&&visited[nextx][nexty] == 0&&map[nextx][nexty] == '*'){dfs(nextx,nexty);}}}int main(){cin>>w>>h;int i,j;for(i = 0;i < h;i++)for(j = 0;j < w;j++)cin>>map[i][j];int max = INT_MIN;for(i = 0;i < h;i++)for(j = 0;j < w;j++){if(map[i][j] == '*'&&visited[i][j] == 0){ans = 0;dfs(i,j);if(max < ans)max = ans;}}cout<<max<<endl;return 0;}
- poj 3051 Satellite Photographs 基础DFS
- poj 3051 Satellite Photographs 很基础的dfs
- POJ 3051 Satellite Photographs 简单DFS
- poj 3051 Satellite Photographs
- poj-3051 Satellite Photographs
- POJ 3051 Satellite Photographs
- POJ 3051 Satellite Photographs
- POJ 3051 Satellite Photographs 可能会
- POJ 3051 Satellite Photographs 笔记
- Satellite Photographs--DFS
- Satellite Photographs(dfs)
- Satellite Photographs(dfs)
- poj 3051 Satellite Photographs dp水题
- POJ 3051 Satellite Photographs 图的连通块,dfs即可。大水题。
- PKU3051 Satellite Photographs 简单DFS
- Satellite photographs——DFS
- Satellite Photographs
- Satellite Photographs
- Java开发和运行环境的搭建
- maven 无法下载bundle类型的问题解决办法
- 混用ATL MFC WTL的问题-CString的冲突
- HOWTO: Customize UIKeyboard
- 12 个免费在线的 Web 网站性能测试工具
- poj 3051 Satellite Photographs 基础DFS
- Javascript调用后台方法
- 英特尔SR-IOV实现PCI硬件资源共享
- Ubuntu 11.10 上很棒的一组主题
- SQLServer 2005 Row_Number 的使用
- FltGetFileNameInformation+VISTA+IRP_MJ_NETWORK_QUERY_OPEN+BSOD
- UIKeyboard
- android Frame-By-Frame Animations(一帧一帧地播放动画)的使用
- iphone ios debug 调试时如何查看、监视变量