問題一覧 > 通常問題

No.2692 How Many Times Reached?

レベル : / AI推定難易度 : 167 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 162
作問者 : m46bSDt / テスター : hibit_at MM
お気に入りにしたユーザー ProblemId : 10637 / 自分の提出
問題文最終更新日: 2024-03-21 14:30:04
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 423 (Asakatsu Presents 3) (順位表) の他の問題:

Problem Statement

$A$ and $B$ are playing a territory game on an $N \times N$ board. The cell in the $i$-th row from the top and the $j$-th column from the left is called cell $(i,j)$ .

Initially, every cell has . written on it.

$A$ and $B$ repeat the following operations.

  1. $A$ chooses exactly $1$ cell with . written on it and repaints it to A.
  2. If the board has a bingo of $A$, then $A$ wins. Otherwise, $B$ chooses exactly $1$ cell with . written on it and repaints it to B.
  3. If the board has a bingo of $B$, then $B$ wins. Otherwise, return to 1.

A bingo is a state in which, for the most recently repainted cell, the same character as that cell continues for $N$ cells along a single vertical, horizontal, or diagonal straight line.

$A$ noticed on a certain turn that there exists a reach of their own.

A reach is a vertical, horizontal, or diagonal straight line that can be turned into a bingo by repainting an appropriate . cell.

Currently, each cell has one of the characters A , B , . written on it.

The characters written on the cells are represented by $N$ strings $S_{1},S_{2},\dots,S_{N}$ of length $N$, and the character written on cell $(i,j)$ is equal to the $j$-th character of the string $S_{i}$.

Find the number of reaches of $A$ on the given board.

Input

$N$
$S_{1}$
$S_{2}$
$\vdots$
$S_{N}$
  • $2 \leq N \leq 100$
  • $S_{i}$ is a string of length $N$ consisting only of A , B , and .
  • It is guaranteed that the given board has at least $1$ reach and is not in a bingo state.

Output

Find the number of lines on which $A$ has a reach on the given board.

Sample

Sample 1
Input
3
A.B
AB.
...
Output
1

$A$ can fill column $1$ with A by repainting cell $(3,1)$.

Sample 2
Input
3
AA.
ABB
.B.
Output
2

$A$ can fill column $1$ with A by repainting cell $(3,1)$.

Also, repainting cell $(1,3)$ fills row $1$ with A.

Sample 3
Input
3
BAB
A.A
BAB
Output
2

$A$ can fill both row $2$ and column $2$ with A by repainting cell $(2,2)$.

In this way, the total number of reaches can be $2$ or more even if only $1$ cell is repainted.

Sample 4
Input
6
AAAAA.
BBBBB.
AAAAA.
BBBBB.
AAAAA.
BBBBB.
Output
3

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。