Vampire’s Treasure

There are many big treasures hidden in the caves! However, it is guarded by a vampire. You want to collect as many of these treasures as possible, while avoiding being catched by the vampire. Luckily, the vampire is quite stupid.

The rules are as follows:

Input

The first line of input contains two numbers XX and YY, which are the dimensions of the board (1X20,1Y151 \leq X \leq 20, 1 \leq Y \leq 15).

The following YY lines contains XX characters each. This is the cave map, made of .#TSV characters. There is at most one S, at most one V, and at most six T.

Output

Output two numbers: the amount of treasure that you are able to collect, and the minimum number of turns required. For now, you do not care about how you will escape the cave...

The solution is as follows (Y-you, V-vampire, y,v-previous positions):

After 8 steps:

....................
.y.....Y..V.........
..y.yyy###.vvv......
...y###y.#.###v###..
....#....#.....v....
....#....#......v...
.................vT.
##...............Tv.
T#..................

After 12 steps:

....................
.y.....vvvv.........
..y.yyV###.vvv......
...y###y.#.###v###..
....#..y.#.....v....
....#...Y#......v...
.................vT.
##...............Tv.
T#..................

After 23 steps:

....................
.y.....vvvv.........
..y.yyv###.vvv......
...y###v.#.###v###..
....#..yv#.....v....
....#...v#......v...
.........v.....vVYy.
##........v...v..yv.
T#.........vvvyyy...

Problem information

Author: Eryk Kopczynski

Generation: 2026-01-25T22:49:26.727Z

© Jutge.org, 2006–2026.
https://jutge.org