Logo
(追記) (追記ここまで)

34398번 - Lost On Campus 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB201816100.000%

문제

You were wandering around the campus at Colorado School of Mines, but you ended up getting lost in some building that you don't recognize. To get out, you'll need to traverse the corridors of the building until you find an exit.

Luckily, while wandering, you're able to find a map of the building that shows you the floor plan (your input). Now you can find a way out!

There's just one problem, however: you have a tragic fear of doors. On the way out of the building, you'll want to go through as few doors as possible.

Given the floor plan of the building, what is the fewest doors you can go through while still reaching an exit?

입력

The first line of your input will contain two integers: $W$ and $H,ドル representing the width and height, respectively, of the map. For all inputs, 3ドル \leq W \leq 100$ and 3ドル \leq H \leq 100$.

The following $H$ lines will each contain $W$ characters, representing the map. The map itself uses the following characters to represent each object:

  • . (period): Floor
  • # (pound sign): Wall
  • D (upper-case D): Door
  • E (upper-case E): Exit
  • * (asterisk): Starting Point (You are here!)

When traversing the map, you can only move from a given tile to its four adjacent tiles: up, down, left, and right.

Additionally, each map will have walls along every edge, and there can be several different exits in the map, which may or may not be adjacent to the edges of the map.

출력

Your output should be a single integer, representing the fewest doors you can go through while still reaching an exit. Also note that going through an exit does not count as going through a door.

If it is impossible to navigate to an exit, output "NOT POSSIBLE".

제한

예제 입력 1

9 12
#########
#E..D.###
#...#.###
#####.###
#.....###
#D#.#D###
#D#D#.#E#
#D#D#.#.#
#.....#D#
#..*..DD#
#.....###
#########

예제 출력 1

2

예제 입력 2

9 10
#########
#...E..D#
#########
#.D....D#
###.*.###
###D.####
####.####
#E.###..#
#.......#
#########

예제 출력 2

NOT POSSIBLE

예제 입력 3

8 8
########
###....#
###E.D.#
#.*##D##
#..##D##
#..DD.##
#..#####
########

예제 출력 3

5

노트

출처

School > CS@Mines > CS@Mines HSPC 2022 > Advanced L번

  • 문제를 만든 사람: Joseph Claver
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /