Problem C
Lines of X
Tic-tac-toe is boring. The optimal strategy is simple to
work out. But what about a generalization to an
Given a
More precisely, compute the number of
-
contains only X or O entries, 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.
Input
The first line of input contains a single integer
Output
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.
Sample Input 1 | Sample Output 1 |
---|---|
2 X. .. |
7 |
Sample Input 2 | Sample Output 2 |
---|---|
2 X. .O |
3 |
Sample Input 3 | Sample Output 3 |
---|---|
3 XO. O.X OXO |
0 |
Sample Input 4 | Sample Output 4 |
---|---|
2 XX XX |
1 |