Logo
(追記) (追記ここまで)

33644번 - Lines of X 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB109888.889%

문제

Tic-tac-toe is boring. The optimal strategy is simple to work out. But what about a generalization to an $N \times N$ board. That also does not seem interesting, and you probably won’t convince anyone to play with you. So you decide to have your own fun with such grids.

Given a $N \times N$ grid $G$ where each cell contains a single X, O, or . (the latter meaning the space is empty), you want to calculate the number of ways one can fill out the empty cells in $G$ so that there is at least one line that is all X. The lines of the grid are the $N$ rows, the $N$ columns, and the 2ドル$ diagonals.

More precisely, compute the number of $N \times N$ grids $H$ that have the following properties:

  • $H$ contains only X or O entries, no empty cells.
  • The only cells where $G$ and $H$ can differ is at the empty cells in $G$.
  • At least one row, column, or diagonal line of $H$ only contains X.

입력

The first line of input contains a single integer $N$ (2ドル≤N≤8$) indicating the dimensions of the grid. The next $N$ lines describe the rows of the grid, each row is a string of length exactly $N$ containing only characters ., O, X.

출력

Output a single number indicating the number of ways to fill out the . characters in the grid with either O or X so that the resulting grid has at least one line with all characters being X.

제한

예제 입력 1

2
X.
..

예제 출력 1

7

예제 입력 2

2
X.
.O

예제 출력 2

3

예제 입력 3

3
XO.
O.X
OXO

예제 출력 3

0

예제 입력 4

2
XX
XX

예제 출력 4

1

힌트

출처

University > University of Alberta Programming Contest > UAPC 2024 > Division 1 C번

University > University of Alberta Programming Contest > UAPC 2024 > Division 2 D번

  • 문제를 만든 사람: Zachary Friggstad
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /