Lines of X
시간 제한3초메모리 제한2048 MB
N x N 격자의 빈 칸을 X 또는 O로 채워서 행, 열, 대각선 중 적어도 하나가 모두 X가 되는 경우의 수를 구한다.
문제
Tic-tac-toe is boring. The optimal strategy is simple to work out. But what about a generalization to an 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 grid 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 so that there is at least one line that is all X. The lines of the grid are the rows, the columns, and the diagonals.
More precisely, compute the number of grids that have the following properties:
- contains only
XorOentries, no empty cells. - The only cells where and can differ is at the empty cells in .
- At least one row, column, or diagonal line of only contains
X.
입력
The first line of input contains a single integer () indicating the dimensions of the grid. The next lines describe the rows of the grid, each row is a string of length exactly 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.