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

6189번 - Munching 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB30819416364.683%

문제

Bessie loves her grass and loves to hurry to the barn for her evening milking session. She has partitioned the pasture into a rectilinear grid of R (1 <= R <= 100) rows and C (1 <= C <= 100) columns and marked the squares as grass or rocky (she can't eat rocks and won't even go into those squares). Bessie starts on her map at location R_b,C_b and wishes to munch her way, square by square, to the barn at location 1,1 by the shortest route possible. She moves from one square to any one of the potentially four adjacent squares.

Below is the original map [with rocks ('*'), grass ('.'), the barn ('B'), and Bessie ('C' for cow) at row 5, col 6] and a route map with the optimal route marked with munches ('m'):

 Map Optimal Munched Route
 1 2 3 4 5 6 <-col 1 2 3 4 5 6 <-col
 1 B . . . * . 1 B m m m * .
 2 . . * . . . 2 . . * m m m
 3 . * * . * . 3 . * * . * m
 4 . . * * * . 4 . . * * * m
 5 * . . * . C 5 * . . * . m

Bessie munched 9 squares.

Given a map, determine how many squares Bessie will eat on her shortest route to the barn (there's no grass to eat on the barn's square).

입력

  • Line 1: Two space-separated integers: R and C
  • Lines 2..R+1: Line i+1 describes row i with C characters (and no spaces) as described above

출력

  • Line 1: A single integer that is the number of squares of grass that Bessie munches on the shortest route back to the barn

제한

예제 입력 1

5 6
B...*.
..*...
.**.*.
..***.
*..*.C

예제 출력 1

9

힌트

출처

Olympiad > USA Computing Olympiad > 2007-2008 Season > USACO US Open 2008 Contest > Bronze 4번

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

출처

대학교 대회

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

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