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

Šah

설명

Two chess giants, Vito and Patrik, will play a game of chess this year in front of
the iconic theater on Jane Street, finally proving who is the greatest player \(of\) all
time. However, as standard chess has become boring for them, they decided to
modify the rules of the game to make it more interesting. We will mention only
the rules that are relevant to this task.
The chessboard will be a square matrix with \(N\) rows and \(N\) columns. Only the
chess pieces knight, rook, and queen will be used. The pieces behave in the
same way as in standard chess. A rook attacks a square if it is in the same row or column as that rook. A
queen also attacks all squares in the same row and column, but in addition to that, it attacks all squares
along the same diagonals. Knights attack squares that are two rows and one column away or vice versa.
Examples of these moves can be seen in the explanations of the examples.
Note: Each piece also attacks the square on which it is placed. Additionally, pieces attack through other
pieces, i.e., a piece attacks squares according to the rules stated above regardless of whether there is
another piece between the square and the attacking piece.
Vito is preparing for the long-awaited showdown and needs your help. He has decided to practice his quick
observation skills. He will do this by placing \(M\) chess pieces on the board and then determining all the
squares that are attacked. Your task is to determine the number of attacked squares on the given board.

제약
입력 형식

The first line contains pozitive integers \(N\) and \(M\) (\(1 \le N \le 200\), \(1 \le M \le N\) ^{2}).
In the next \(M\) lines, each line contains a single uppercase letter of the English alphabet, representing
the type of piece, which can be one of ’N’, ’R’, and ’Q’, corresponding to knight, rook, and queen,
respectively, and integers \(r_{i}\) and \(c_{i}\) (\(1 \le r_{i}\), \(c_{i} \le N\)), representing the row and column where that piece is
located.
At most one piece can be placed on any square of the board.

출력 형식

In the first and only line, you need to output the number of attacked squares on the board.

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

1

13점

All pieces on the board are rooks.

2

19점

Each piece on the board is either a rook or a queen.

3

18점

No additional constraints.

예제 1
입력
7 1
Q 4 4
출력
25
예제 2
입력
5 1
N 3 3
출력
9
예제 3
입력
6 3
R 1 4
Q 2 1
N 5 2
출력
25
설명

Clarification of the first and second example: In the sketches, examples are shown. All attacked
squares are marked with a dot, except the one on which the piece is located.
(a) first example
(b) second example

문제 정보

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

출처 COCI 2024/2025 Contest 4

평가 및 의견

Šah

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

Log in to rate problems.

개별 의견

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

풀이 제출

Šah

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