HDU Oil Deposits
来源:互联网 发布:xshell linux版 编辑:程序博客网 时间:2024/04/30 04:07
简单搜索
#include <iostream>#include <cstdio>#include <queue>#include <cstring>#include <cmath>#include <vector>#include <set>#include <stack>#include <algorithm>//#include "myAlgorithm.h"#define MAX 105#define INF (1e8 + 5)#define eps 1e-8#define Rep(s, e) for( int i = s; i <= e; i++)#define Cep(e, s) for( int i = e; i >= s; i --)using namespace std;int n, m;char str[MAX][MAX];int ans = 0;int dir[][2] = {{ -1, 0},{1, 0},{0, -1}, {0, 1}, {1, 1}, {-1, -1}, {1, -1}, {-1, 1}};///eight directionstruct Point{ int y , x;};void bfs(Point start){ ans ++; queue<Point>q; q.push(start); str[start.y][start.x] = '*';//set wall; Point tt, temp; while(!q.empty()){ temp = q.front(); q.pop(); Rep(0, 7){ int I = temp.y + dir[i][0], J = temp.x + dir[i][1]; if(I > -1 && J > -1 && I < m && J < n && str[I][J] == '@'){ str[I][J] = '*';// set wall; tt.y = I; tt.x = J; q.push(tt); } } }}void solve(){ Point start; ans = 0; Rep(0, m - 1){ for(int j = 0; j < n;j++){ if(str[i][j] == '@'){ start.y = i; start.x = j; bfs(start); } } } cout<<ans<<endl;}int main() { //freopen("in.tx0t", "w", stdout); while(cin>>m>>n, m){ getchar(); Rep(0, m - 1){ cin>>str[i]; }///end input solve(); } return 0;}/**/
- HDU 1241Oil Deposits
- HDU---1241Oil Deposits
- HDU-1244-Oil Deposits
- Hdu 1241 Oil Deposits
- Hdu 1241 - Oil Deposits
- HDU-1241:Oil Deposits
- HDU Oil Deposits
- hdu 1241 Oil Deposits
- hdu 1241 Oil Deposits
- hdu 1241 Oil Deposits
- hdu - 1241 - Oil Deposits
- HDU-1241Oil Deposits
- hdu 1241 Oil Deposits
- hdu 1241 Oil Deposits
- HDU 1241 Oil Deposits
- hdu 1241 Oil Deposits
- hdu 1241 Oil Deposits
- HDU 1241 Oil Deposits
- 动态获取资源ID
- 归并排序
- 浅谈SUN JVM内存管理与应用服务器的优化之 服务器内存分配与优化
- 骂人的最高境界。就是淡定!!
- 九度OJ 题目1079:手机键盘
- HDU Oil Deposits
- ExecutorService线程池 转自 http://blog.sina.com.cn/s/blog_6151984a0100krj8.html
- Linux 字节对齐问题
- 成熟
- ubuntu root用户登录及解决没有声音的问题
- sql server xml二
- 团队工作日志入驻CSDN
- 关于Spring3与Hibernate4整合错误:java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
- Android源码下载