A16 - Dungeon 1(※初版第 1 刷の B22 も同じ問題です)

AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.