## Back From Summer '19 P2: Straying From God's Light

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Java 1.8s
Memory limit: 128M

Authors:
Problem type

Marcus is stuck in a -dimensional grid of size , consisting of . for walkable spaces and # for unwalkable spaces! He is at the top left corner (position ) and must travel to the bottom right corner (position ) through only walkable spaces. He can only move left, right, and down. In a path, let be the number of times he moves down, left, and right, respectively. Let the cost of the path be . Marcus wants to find a path from to that has the minimum cost.

#### Input Specification

The first line will contain the integer , the size of the grid.

The next lines will each contain characters, either . for a walkable space or # for an unwalkable space. The first character of the first line will be position and the character of the line will be position .

It is guaranteed positions and will be walkable (.).

#### Output Specification

Output the minimum cost path for Marcus. If there is no path, output -1.

#### Sample Input

6
......
.#....
##.##.
......
.#####
......

#### Sample Output

78

#### Explanation For Sample

The minimum cost path consists of moving down units, left units, and right units, for a total of .

• commented on Sept. 3, 2019, 10:54 p.m. edit 2

>:(

• commented on Sept. 4, 2019, 1:45 a.m.

every

• commented on Sept. 4, 2019, 1:46 a.m.

day

• commented on Sept. 4, 2019, 1:46 a.m.

Marcus

• commented on Sept. 4, 2019, 1:47 a.m.

strays

• commented on Sept. 4, 2019, 1:50 a.m.

further

• commented on Sept. 4, 2019, 1:53 a.m.

from

• commented on Sept. 4, 2019, 1:54 a.m.

god's

• commented on Sept. 4, 2019, 1:55 a.m. edited

light.

• commented on Sept. 4, 2019, 2:30 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Nov. 17, 2019, 5:37 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.