COCI '10 Contest 6 #6 Voda

View as PDF

Submit solution


Points: 20 (partial)
Time limit: 5.0s
Memory limit: 128M

Problem type

Mirko, the mad plumber, was hired to construct a water supply network between two locations in a city. The city map can be represented as an R \times S grid. Some cells are not suitable for placing water pipes. Locations Mirko needs to connect are placed directly above the top left cell of the grid, and directly below the bottom right cell.

Each suitable cell Mirko can either leave empty or use it for placing one of the following 6 pipe types:

Find the number of ways that pipes can be placed to connect the two locations with a continuous pipe (water must not be spilled). All placed pipe parts must be in use.

Output the solution modulo 10\,007.

Input Specification

The first line of input contains the integers R and S (2 \le R, S \le 10), the number of rows and columns of the city grid, respectively. Each of the next R lines contains exactly S characters: . if the cell is suitable for placing pipes, and # if not.

Output Specification

The first and only line of output must contain the required number of ways modulo 10\,007.

Sample Input 1

2 3
...
.#.

Sample Output 1

1

Explanation for Sample Output 1

This is the only possible solution:

Sample Input 2

3 3
...
...
...

Sample Output 2

12

Comments

There are no comments at the moment.