포럼
문제 ICPC00372

L. Linguistic Labyrinth

설명

It is the 25th of December, 2025. As a Christmas tradition, you gather a group of friends to solve a puzzle. Among your friends are wordcels and shape rotators, who are respectively better at thinking with words and with mental images. This puzzle challenges even the smartest wordcel and the most brilliant shape rotator:

There is a \(3\)-dimensional grid with points at all integer coordinates \((x,y,z)\) with \(1\leq x,y,z\leq n\), and each point has a label associated with it, which is either 'B', 'A', 'P', or 'C'. In this grid, you need to find occurrences of the curly word "BAPC". A curly word "BAPC" is a collection of four points in the grid such that:
- The labels spell out "BAPC" (in this order).
- The angle that the triplet "BAP" makes is \(90\) degrees: the vectors from \(\texttt{B}\to \texttt{A}\) and from \(\texttt{A}\to \texttt{P}\) form a \(90\)-degree angle.
- The angle that the triplet "APC" makes is \(90\) degrees: the vectors from \(\texttt{A}\to \texttt{P}\) and from \(\texttt{P}\to \texttt{C}\) form a \(90\)-degree angle.

Note that the two angles do not need to be axis-aligned. As an example, see the third sample case, visualized in Figure .

How many occurrences of the curly word "BAPC" are in the given grid?

제약
입력 형식

The input consists of:
- One line with an integer \(n\) (\(1\leq n\leq 22\)), the size of the grid.
- \(n\) blocks of \(n+1\) lines. Each block of \(n+1\) lines consists of:
- One line with a hyphen (-), to make the input more human-readable.
- \(n\) lines with \(n\) characters, each character being either 'B', 'A', 'P', or 'C',

representing all labels of one horizontal layer of the \(3\)-dimensional grid.

출력 형식

Output the number of curly words "BAPC" in the \(3\)-dimensional grid.

예제 1
입력
1
-
B
출력
0
예제 2
입력
2
-
PA
PB
-
CC
PB
출력
2
예제 3
입력
3
-
BBB
BCB
BCB
-
BBC
CBA
BBB
-
BBB
BPB
BBB
출력
2
문제 정보

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

출처 ICPC BAPC 2025

평가 및 의견

L. Linguistic Labyrinth

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

Log in to rate problems.

개별 의견

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

풀이 제출

L. Linguistic Labyrinth

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