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

32330번 - Harvest Waterloo 서브태스크다국어

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

문제

There is a wildly popular new harvest simulation game called Harvest Waterloo. The game is played on a rectangular pumpkin patch which contains bales of hay and pumpkins of different sizes. To begin the game, a farmer is placed at the location of a pumpkin.

The farmer harvests all pumpkins they can reach by moving left, right, up, and down throughout the patch. The farmer cannot move diagonally. The farmer can also not move through a bale of hay nor move outside of the patch.

Your job is to determine the total value of all the pumpkins harvested by the farmer. A small pumpkin is worth \1,ドル a medium pumpkin is worth \5,ドル and a large pumpkin is worth \10ドル dollars.

입력

The first line of input is an integer R > 0 which is the number of rows within the patch.

The second line of input is an integer C > 0 which is the number of columns within the patch.

The next R lines describe the patch. Each line will contain C characters and each character will either represent a pumpkin size or a bale of hay: S for a small pumpkin, M for a medium pumpkin, L for a large pumpkin, or * for a bale of hay.

The next line of input is an integer A where 0 ≤ A < R, and the last line of input is an integer B where 0 ≤ B < C. Row A and column B is the starting location of the farmer and the top-left corner of the patch is row 0 and column 0.

출력

Output the integer, V , which is the total value in dollars of all the pumpkins harvested by the farmer.

제한

서브태스크

Subtask Score Description Bound
1 1 The patch is small and there are no bales of hay. R × C ≤ 100
2 3 The patch is small and the bales of hay divide the entire patch into rectangular areas. R × C ≤ 100
3 5 The patch is small and the bales of hay can be anywhere. R × C ≤ 100
4 4 The patch is large and the bales of hay can be anywhere. R × C ≤ 100 000

예제 입력 1

6
6
**LMLS
S*LMMS
S*SMSM
******
LLM*MS
SSL*SS
5
1

예제 출력 1

37

Starting at row 5 and column 1, the farmer can reach the 6 pumpkins in the highlighted area. They harvest 2 small pumpkins, 1 medium pumpkin, and 3 large pumpkins. The total value in dollars of this harvest is 2 × 1 + 1 × 5 + 3 × 10 = 37.

예제 입력 2

6
6
**LMLS
S*LMMS
S*SMSM
***SLL
LLM*MS
SSL*SS
2
4

예제 출력 2

88

Starting at row 2 and column 4, the farmer can reach the 19 pumpkins in the highlighted area. They harvest 8 small pumpkins, 6 medium pumpkin, and 5 large pumpkins. The total value in dollars of this harvest is 8 × 1 + 6 × 5 + 5 × 10 = 88.

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2024 > CCC 2024 Junior Division 5번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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