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

View as PDF

Points: 7 (partial)
Time limit: 2.0s
Java 4.0s
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.

No further constraints.

#### 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 .

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

>:(

• crackersamdjam  commented on Sept. 3, 2019, 9:45 p.m.

every

• zxyl  commented on Sept. 3, 2019, 9:46 p.m.

day

• Plasmatic  commented on Sept. 3, 2019, 9:46 p.m.

Marcus

• Pookmeister  commented on Sept. 3, 2019, 9:47 p.m.

strays

• Beautiful_Times  commented on Sept. 3, 2019, 9:50 p.m.

further

• richardzhang  commented on Sept. 3, 2019, 9:53 p.m.

from

• Rimuru  commented on Sept. 3, 2019, 9:54 p.m.

god's

• Jacky  commented on Sept. 3, 2019, 9:55 p.m. edited

light.

• microwave  commented on Sept. 3, 2019, 10:30 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.