标签:ring std log har cti 允许 重复 include font
输入
输出
示例输入
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0
示例输出
45 59 6 13
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<set> #include<vector> #include<stack> #include<queue> #include<algorithm> #include<cstdio> #include<algorithm> #include<functional> #include<sstream> int W, H; char z[21][21]; int f(int x, int y) { if (x < 0 || x >= W || y < 0 || y >= H) return 0; if (z[x][y] == ‘#‘) { return 0; } else { z[x][y] = ‘#‘; return 1 + f(x - 1, y) + f(x + 1, y) + f(x, y - 1) + f(x, y + 1); } } int main(int argc, char* argv[]) { int i, j, num; while (scanf("%d%d", &H, &W) && W != 0 && H != 0) { for (i = 0; i < W; i++) scanf("%s", z[i]); for (i = 0; i < W; i++) for (j = 0; j < H; j++) if (z[i][j] == ‘@‘) printf("%d\n", f(i, j)); } return 0; }
标签:ring std log har cti 允许 重复 include font
原文地址:http://www.cnblogs.com/edych/p/7236323.html