ÀÂÒ
Language: Russian
English

Remote Training on Programming

Problems Online status Contests
News FAQ E-learning
For authors:
Register  ||  Login
 
Hello, Guest! Please login or register.

890. Maze

Time Limit: 1 seconds
Memory Limit:65536KB
Points:100
View Problem Statistics Submit Problem added 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

 


View Problem Statistics Submit Problem discussion Author/source:
Sorted Problems / Graphs /
267. From Fly to Elefant 890. 9. Net 292. One-way Racing 246. Path in Labyrinth
Problems from Contests and Camps / World Championship in Programming (ICPC) / Rybinsk-2010 /
889. D - Bubble 890. 891. F - Tree packing 892. G - Solar eclipse 893. H - Green wave
Problems from Contests and Camps / Trainings of Vologda SU / Graphs: traversal and shortest paths /
205. D - Èãðà â ãîðîäà 890.
time generating 0.109 sec.
© Copyright VSU, AVT, Nosov D.A., Andrianov I.A.