АВТ
Язык:

Дистанционный практикум по программированию

Задачи Online статус Соревнования
Новости Справка СДО
 
Здравствуйте, Гость! Войдите с паролем или зарегистрируйтесь.

890. Лабиринт.

Ограничение времени: 1 сек.
Ограничение памяти:65536 КБайт
Баллы:100
Статистика Послать на проверку Задачу добавил debug

Consider a maze of size N by M. Each cell of the maze may be either free, or occupied by a wall. The maze is surrounded by a wall, which has two free cells, entry and exit. The entry is always in the left border of the maze, while the exit is in the right. It is allowed to move in four directions: up, down, left, right. Diagonal moves are forbidden. There is always a path between the entry and the exit.

Such a maze may have several possible paths between the entry and the exit. However, there are cells that will be visited in any case.

Write a program to calculate the number of cells belonging to each path from the entry to the exit.

Limitations

3 ≤ N, M ≤ 999

Input

The first line contains two integer numbers N and M, the dimensions of the maze. The following N lines of M characters describe the maze. Character "#" denotes a wall, and character '.' denotes a free cell.

Output

The output file must contain a single integer – the number of cells belonging to each path from the entry to the exit.

Sample

Standard input

Standard output

7 7
#######
....#.#
#.#.###
#.....#
###.#.#
#.#....
#######

5

 


Статистика Послать на проверку Обсуждение задачи Автор/источник:
Задачи по темам / Графы /
201. Кратеры на Луне 890. 208. Михаил Густокашин против бюрократии 267. Муха - слон 170. ОДМС
Задачи с соревнований и сборов / Чемпионат мира по программированию (ICPC) / Рыбинск-2010 /
889. D - Пузырёк 890. 891. F - Упаковка дерева 892. G - Солнечное затмение 893. H - Зелёная волна
Задачи с соревнований и сборов / Тренировки ВоГУ / Графы: обходы и кратчайшие пути /
205. D - Игра в города 890.
 
время генерации 0.094 сек.
© Copyright ВоГУ, АВТ, Носов Д.А., Андрианов И.А.