Can anyone help me with this problem?

Revision en3, by thanhchauns2, 2021-05-14 09:07:07

Given a map of a dungeon, your task is to take all TWO diamonds in the dungeon. Find the minimum number of gates you have to open to take all the diamonds. Note: It can be more than one gate to go into the dungeon from the outside. You can move up, down, left, right or diagonal About the map: — The letter '.' means blank space, you can move on it — The letter '*' means blockade, you have to go around it — The letter '#' means there's a gate at that place, you need it opened to go through it — The letter '\$' means the diamond. Input format: — First line is two number N and M — the dungeon has the size N*M. — N lines following, represent the map of the dungeon. Output format: — A single integer — the minimum number of gates you have to open. Example input: 5 9

• # * * * *

• . . # . # . . *

• . * * * *
• $# . # . #$ *

• * Example output: 4

Thank you guys, hope you have a great standing in the next contest.

#### History

Revisions

Rev. Lang. By When Δ Comment
en11 thanhchauns2 2021-05-14 09:46:39 13 Tiny change: 'eft, right or diagonal\n\nAbout ' -> 'eft, right.\n\nAbout '
en10 thanhchauns2 2021-05-14 09:38:15 28
en9 thanhchauns2 2021-05-14 09:36:35 44
en8 thanhchauns2 2021-05-14 09:13:31 95
en7 thanhchauns2 2021-05-14 09:12:17 173
en6 thanhchauns2 2021-05-14 09:08:50 86
en5 thanhchauns2 2021-05-14 09:07:47 8
en4 thanhchauns2 2021-05-14 09:07:31 42 Reverted to en1
en3 thanhchauns2 2021-05-14 09:07:07 40 (published)
en2 thanhchauns2 2021-05-14 09:06:15 2 Tiny change: 'tput:\n4\nThank yo' -> 'tput:\n4\n\nThank yo' (saved to drafts)
en1 thanhchauns2 2021-05-14 09:06:00 1039 Initial revision (published)