#P10386. Draw Board Count in 5×5 Gomoku

    ID: 12393 Type: Default 1000ms 256MiB

Draw Board Count in 5×5 Gomoku

Draw Board Count in 5×5 Gomoku

Two close friends, Blue and Qiao, decide to play Gomoku on a 5×5 board using white (Blue) and black (Qiao) pieces. In accordance with the motto "Friendship first, game second", they agree that whatever happens, the game should end with a draw.

The game is played under the following rules:

  1. Board size: The game is played on a 5×5 grid (25 cells in total).
  2. Pieces: There are two types of pieces: white and black. Blue holds white and Qiao holds black.
  3. First move: White (Blue) always moves first on an empty board.
  4. Alternate moves: Players take turns placing one piece per turn until the board is full.
  5. Win condition: The first player to achieve 5 consecutive same‐colored pieces in a row, column or (diagonal) wins.
  6. Draw condition: If all 25 cells are filled and no winning five-in-a‐row (in any direction) exists, the game is declared a draw.

The two friends wonder: How many different final board configurations are possible such that the board is completely filled (with exactly 13 white pieces and 12 black pieces, adhering to the move order since white goes first) and no winning line (horizontal, vertical, or diagonal) occurs? (Note that a final board configuration is considered the same regardless of the order in which the moves were played.)

In other words, count the number of full-board assignments (choosing 13 cells for white and the remaining 12 for black) that have no row, column, or the two main diagonals entirely filled with the same color. Any occurrence of a five‐in‑a‑row (in any of these 12 lines) would have meant a win and is not allowed.

Hint on the mathematical formulation: The board is fixed at 5×5, and the placement must satisfy:

  • Exactly 13 white and 12 black pieces (since white always moves first).
  • No row (5 cells), no column (5 cells), and neither the main diagonal nor the anti‑diagonal (each 5 cells) is uniformly white or uniformly black.

You are to output the count of such board configurations.

inputFormat

This problem has no input.

outputFormat

Output an integer representing the number of valid full-board draw configurations.

sample

3093300