Type: Default 1000ms 256MiB

瓷砖

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

在一个w×h的矩形广场上,每一块1×1的地面都铺设了红色或黑色的瓷砖。小林同学站在某一块黑色的瓷砖上,他可以从此处出发,移动到上、下、左、右四个相邻的且是黑色的瓷砖上。现在,他想知道,通过重复上述移动所能经过的黑色瓷砖数。

输入格式

第1行为h、w,2≤w、h≤50,之间有一个空格隔开。

以下为1个w行h列的二维字符矩阵,每个字符为“.”“#”“@”,分别表示该位置为黑色的瓷砖、红色的瓷砖、小林的初始位置。

输出格式

输出一行一个整数,表示小林从初始位置出发经过的黑色瓷砖数。

30 17
##...#...#.#.#..####.#........
.#.#...##....##.....###.#.##..
#..#..#...#......##...#....#.#
........#.#####...##.......##.
.........#.#.####.#........##.
........#.#.###...........#.##
#...####.#..#....##....###.#..
...####.#.#..####.......#....#
.#..#.@#.#.....#...#...#.#...#
##..#..#.......###..#....#....
.##....###...##..##..##..##..#
..#.#.#.#.#...#.......####..#.
.........###.#...#.#..#..#.###
.....##...#.#...##..#####..#..
...#.#.....##.#.......##..#...
.#......##....#...#.....#...#.
####..####.#..#.............##

292

周日9:00 阶段测试24-12-28

Not Attended
Status
Done
Rule
OI
Problem
6
Start at
2024-12-28 13:00
End at
2025-1-5 21:00
Duration
200 hour(s)
Host
Partic.
10