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

Labirint

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

의견: 0

설명

What \(is\) \(an\) EJOI for you?
Game room!
Teo is searching for the Croatian EJOI team! She has already found Gabriel, but
is still looking for Vito, Dino, and Ivo.
Teo and the EJOI team are in a labyrinth consisting of \(n \times m\) rooms, all of the
same size. The rooms form a grid. The t\(op-le\)ft room is labeled with (1, 1), and
the bott\(om-ri\)ght with (n, m). Between each pair of adjacent rooms, there is a door
colored in one of four colors: blue (marked with ’P’), red (marked with ’C’), green (marked with ’Z’) and
orange (marked with ’N’).
Illustration \(of\) the third example. The black circle marks the room \(in\) which Teo and Gabriel are located
\(at\) \(in\) the fourth question, and the white circle marks the room \(in\) which Vito, Ivo and Dino are located at.
The gray path \(is\) one \(of\) the possible paths that passes through three different door colors.
At some point, Gabriel says: \(I\) know where the rest \(of\) the team is, but \(I\) will only tell you \(if\) you can
answer all \(of\) \(my\) questions.
Gabriel’s questions are: \(If\) \(we\) are currently \(in\) room (\(a@@RISE_MATH_BLOCK_0@@i\), d\(i\)),
what \(is\) the minimum number \(of\) door colors \(we\) have \(to\) \(go\) through \(to\) reach them?
Teo is very good at answering Gabriel’s questions, but there are simply too many of them. She does not
have much time (the bus is leaving soon), so she is asking you to help her answer \(q\) of Gabriel’s questions!

제약

Subtask 1 (11 points): \(n = 1\)

Subtask 2 (13 points): All doors that connect rooms (\(i\), \(j\)) with (\(i\), \(j + 1\)) are blue, and all doors that connect rooms (\(i\), \(j\)) with (\(i + 1\), \(j\)) are red.

Subtask 3 (24 points): Every door is either red or blue.

Subtask 4 (22 points): No additional constraints.

입력 형식

The first line contains integers \(n\) and \(m\) (\(1 \le n\), \(m \le 100\), \(1 < n \times m\)), the number of rooms.
The \(i-th\) of the following \(n\) lines contains \(m - 1\) characters (’P’, ’C’, ’Z’ or ’N’), where the \(j-th\) character
marks the colour of the door that connects rooms (\(i\), \(j\)) and (\(i\), \(j + 1\)).
The \(i-th\) of the following \(n - 1\) lines contains \(m\) characters (’P’, ’C’, ’Z’ or ’N’), where the \(j-th\) character
marks the colour of the door that connects rooms (\(i\), \(j\)) and (\(i + 1\), \(j\)).
The next line contains the integer \(q\) (\(1 \le q \le 100\)), the number of Gabriel’s questions.
In the \(i-th\) of the following \(q\) lines, there are four integers \(a@@RISE_MATH_BLOCK_0@@i\), \(c@@RISE_MATH_BLOCK_1@@i\) (\(1 \le a@@RISE_MATH_BLOCK_2@@i\), d\(i \le m\),
(\(a_{i}\), b_{i})̸ = (\(c_{i}\), d_{i})), the description of Gabriel’s \(i-th\) question.

출력 형식

In the \(i-th\) of \(q\) lines, output the answer to Gabriel’s \(i-th\) question.

서브태스크
서브태스크점수설명

1

11점

\(n = 1\)

2

13점

All doors that connect rooms (\(i\), \(j\)) with (\(i\), \(j + 1\)) are blue, and all doors that connect rooms (\(i\), \(j\)) with (\(i + 1\), \(j\)) are red.

3

24점

Every door is either red or blue.

4

22점

No additional constraints.

예제 1
입력
1 8
CPZNCCP
4
1 1 1 8
1 3 1 5
1 8 1 4
1 2 1 3
출력
4
2
3
1
예제 2
입력
3 3
PP
PP
PP
CCC
CCC
3
1 1 3 3
3 3 2 2
1 1 1 3
출력
2
2
1
예제 3
입력
4 4
CCC
CPC
PPP
CNP
ZZZZ
PPPP
CPZC
4
3 1 2 3
1 1 4 4
2 2 3 3
1 4 4 1
출력
1
2
1
3
설명

Clarification of the third example:
The third example is illustrated in the text.
For the first question, Teo and Gabriel can use just the blue doors to reach the rest of the team; for the
second question, they can use blue and green doors; for the third again only blue is enough; and for the
fourth, they can use blue, green, and red doors.

문제 정보

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

출처 COCI 2023/2024 Contest 1

평가 및 의견

Labirint

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

Log in to rate problems.

개별 의견

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

풀이 제출

Labirint

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