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

33656번 - Island Exploration 다국어

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

문제

Oh no! You just washed ashore after a shipwreck! Time to put all of those survival skills you have learned in video games to the test.

Some items washed ashore with you, including a map of the area! The map is very crude, the region is represented by a grid and each cell is simply indicated to be “land” or “sea”. After looking at your surroundings a bit, you know which grid cell you are currently standing on. You are able to walk between two land grid cells if they are directly adjacent, i.e. either up, down, left, or right of your current cell (you cannot hop diagonally to a land cell).

The first thing you want to know is how much of the region you are able to explore. That is, your task is to determine how many land cells you are able to walk to.

입력

The first line of input contains two integers $R$ (3ドル≤R≤100$) and $C$ (3ドル≤C≤100$). The next $R$ lines contain exactly $C$ characters each. The $i$’th character on the $j$’th such line is # if the corresponding grid cell is land, . if the corresponding grid cell is sea, or S if you are currently standing on the grid cell.

There will be exactly one S in the input and that cell is also a land cell. Also, the entire boundary of the region will consist of sea cells. That is, the first and last line will consist entirely of . as will the first and last character of every line describing the region.

출력

Output a single integer indicating the number of land cells you are able to walk to from your starting cell. This count should also include the land cell you are initially standing on.

제한

예제 입력 1

4 5
.....
.#S#.
...#.
.....

예제 출력 1

4

예제 입력 2

3 4
....
.#S.
....

예제 출력 2

2

예제 입력 3

3 5
.....
.#.S.
.....

예제 출력 3

1

예제 입력 4

5 7
.......
.S#..#.
.##.##.
..##.#.
.......

예제 출력 4

6

힌트

출처

University > University of Alberta Programming Contest > UAPC 2025 > Division 1 D번

University > University of Alberta Programming Contest > UAPC 2025 > Division 2 F번

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

출처

대학교 대회

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

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