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

26541번 - Field Navigation 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB31252086.957%

문제

Your field has become quite cluttered, and you just realized you left your best hat out in the middle of the pasture. You have to go retrieve it before it stays out any longer than it already has, but you’re also lazy. And there are many obstacles in the way. You have a sickle to cut tall grass, and an axe to chop up any wood in the way, as well as a hammer to destroy rocks you can’t get through, but you don’t want to have to carry them all. Given the location of your hat and the layout of the field and all the obstacles, determine the minimum number of tools you’ll have to bring to reach your prized hat.

입력

The first line will contain a single integer n that indicates the number of data sets that follow. Each data set will start with a single integer s denoting the side length of your square field. The next s lines will consist of a map of your field, with ‘.’ denoting open space, ‘X’ denoting your hat, ‘S’ denoting your starting position leaving your house, ‘R’ denoting a rock, ‘B’ denoting a branch, and ‘G’ denoting tall grass. You can only move up, down, left, and right. No diagonals.

출력

For each test case, output the minimum number of tools needed to retrieve your hat.

제한

예제 입력 1

3
5
S....
GGGG.
.....
.RRRR
....X
7
BRBRGGG
RGGGGRG
BGBBRRG
RGGGGRG
BBRBGBG
GGRBGRG
SGGGGRX
4
GGGX
RRRG
BBRG
SBRG

예제 출력 1

0
1
3

힌트

출처

School > PLU High School Programming Contest > PLU 2017 > Advanced 9번

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

출처

대학교 대회

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

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