poj1979 解题报告
来源:互联网 发布:mac安装windows 编辑:程序博客网 时间:2024/06/07 01:05
#include<iostream>#include<cstdio>char field[100][100];int M=100, N=100;int dx[4] = { -1, 1, 0, 0 }, dy[4] = { 0, 0, 1, -1 };int count = 0;int ans[100];int k = 0;void dfs(int x, int y){field[x][y] = '@';for (int i = 0; i < 4; i++){int nx = x + dx[i], ny = y + dy[i];if (0 <= nx&&nx < M && 0 <= ny&&ny < N&&field[nx][ny] == '.'){field[nx][ny] = '@';count++;dfs(nx, ny);}}return;}int main(void){while (1){count = 0;char ch;scanf("%d%d", &N, &M);while ((ch = getchar()) != '\n')continue;if (N == 0 && M == 0)break;for (int i = 0; i < M; i++)gets(field[i]);for (int i = 0; i < M; i++)for (int j = 0; j < N; j++){if (field[i][j] == '@'){dfs(i, j);}}ans[k] = count+1;k++;}for (int i = 0; i <k; i++)printf("%d\n", ans[i]);}
0 0
- poj1979 解题报告
- POJ1979 /Openjudge1818 Red and Black解题报告(深度优先搜索,图的遍历)
- poj1979解体报告(挑战程序设计竞赛)
- POJ1979
- poj1979
- POJ1979
- POJ1979
- poj1979
- poj1979
- poj1979
- poj1979
- poj1979
- poj1979
- poj1979
- 【POJ1979】
- poj1979
- POJ1979
- 解题报告
- Android 中关于属性动画的一些思考,或许能为你解决一定的性能问题
- 透倜叹固伪始课滦剿腾魏讨液懦腾
- css中float:left之后父对象高度不被撑开的解决办法
- javascript Date format(js日期格式化)
- 文件编程(5)串口应用编程
- poj1979 解题报告
- hdu 5131 Song Jiang's rank list (水题)
- windows 下使用 MinGW + msys 编译 ffmpeg
- LTE资源
- ascasc
- new模态和非模态对话框的建立和释放
- sdvsdzvzdxv
- css基础-布局模型
- 运输船搁浅殃及千辆路虎和劳斯莱斯 损失上亿英镑