RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00532

Zoo

Unrated 레이팅 미적용
난이도
2s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

On a cold Christmas night in 2010, Zagreb was covered in snow. Zdravko decided
to leave his castle, cross the road and take a stroll through the Maksimir park.
Unfortunately, the idyllic winter evening was interrupted by a monster that
was lurking in the nearby bushes. The monster jumped in front of Zdravko, but
Zdravko roared a mighty roar which scared the monster away. Unbeknownst
to him, a bunch of animals from the nearby zoo were startled by that roar.
More precisely, a group of tigers and bulls were so annoyed that they decided
to escape the zoo in order to find a nice quiet place to sleep.
During their escape, the animals had to pass through a rectangular area divided
in \(R \times C\) unit squares. The animals must enter the area through the upp\(er-le\)ft
corner and must leave the area through the low\(er-ri\)ght corner. In order to
escape as quietly as possible, animals will pass through this area one by one,
walking along an arbitrary path in four general directions (up, down, left and right). In other words,
each animal does not necessarily travel along a shortest path during its escape and it might step on the
same unit square more than once (including the entrance and exit). Since the ground is covered in snow,
animals leave footprints when they step inside unit squares. If another footprint is already in the square
that is about to be stepped on, the animal will erase the previous footprint and leave a new one.
Your task is to determine the minimal number of animals that have escaped the Maksimir zoo based on
the footprints that were left in the aforementioned rectangular area.

제약

Subtask
Score
Constraints
1
45
\(2 \le R\), \(C \le 100\)
2
65
\(2 \le R\), \(C \le 1000\)

입력 형식

The first line contains two integers \(R\) and \(C\) from the task description.
The next \(R\) lines contain \(C\) characters that represent the rectangular area from the task description.
Character T represents a tiger’s footprint, character B represents a bull’s footprint and character *
represents untouched snow.
You can assume that the input data is such that at least one animal entered the rectangular area and that
each animal that entered the area has also left the area according to the rules from the task description.

출력 형식

Output the minimal number of animals that have escaped the zoo.

예제 1
입력
4 4
TT*T
*TTT
***T
***T
출력
1
예제 2
입력
3 5
TTBB*
*T*B*
*TTTT
출력
2
예제 3
입력
7 5
BT***
BTBBB
BTTTB
BBT*B
BBT*B
BBT**
*BBBB
출력
3
설명

Clarification of the second example:

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2019/2020 Contest 1

평가 및 의견

Zoo

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Zoo

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8