#P9723. Chinese Checkers Moves

    ID: 22870 Type: Default 1000ms 256MiB

Chinese Checkers Moves

Chinese Checkers Moves

Prof. Pang is playing Chinese Checkers on a hexagonal board (as shown in the figure). The board consists of all cells in an axial coordinate system satisfying \(|x|, |y|, |x+y| \le 4\). There are n checkers placed on the board at distinct positions. The checkers are indistinguishable. A move is performed as follows:

  • First, choose one checker at position \(a\) to move.
  • A move consists of one or more steps. In each step, you select a pivot checker \(b\) (which is not the moving checker) so that the segment joining \(a\) and \(b\) is parallel to one of the three axes of the board. (In this board the three axes are along the directions of the vectors \((1,0)\), \((0,1)\), and \((-1,1)\); note that the opposite directions are also allowed.)
  • Then, the moving checker at \(a\) is reflected about \(b\) to a new position \(a' = 2b - a\). In other words, if \(a=(x,y)\) and \(b=(x_b,y_b)\), then \(a' = (2x_b-x,\;2y_b-y)\).
  • Along the line from \(a\) to \(a'\) (that is, the cells \(a+i\,d\) for \(i=1,2,\ldots,2k-1\) where \(d\) is the chosen direction and \(k\) is chosen so that \(b=a+k\,d\)), all cells except the pivot cell (i.e. the one corresponding to \(i=k\)) must be empty. Also, the pivot \(b\) must be occupied by a checker. Furthermore, the destination \(a'\) must be on the board and empty.
  • Important: In any step, if the new position \(a'\) equals the original starting position of the moving checker (i.e. the position before the move began), then this step is disallowed. (However, it is not forbidden to revisit a cell reached earlier in the move as long as it is not the initial cell.)
  • A move consists of one or several steps. After each step (including the first) Prof. Pang may stop moving the checker.

The final configuration of the board is defined by taking the original configuration and replacing the original position of the moving checker with its new position after the move. Two moves are considered different if and only if the final configuration (i.e. the set of checker positions) is different. Prof. Pang may choose any checker to move. Output the number of different moves (i.e. different final configurations) possible on the current board.

Note: The board consists of all integer axial coordinates \((x,y)\) satisfying \(|x|, |y|, |x+y| \le 4\>.

inputFormat

The first line contains an integer n (1 ≤ n ≤ 61), the number of checkers on the board.

Each of the next n lines contains two integers x and y, denoting the axial coordinates of a checker. It is guaranteed that each given position satisfies \(|x|, |y|, |x+y| \le 4\) and that no two checkers occupy the same cell.

outputFormat

Output a single integer: the number of different moves (i.e. final board configurations) that Prof. Pang can make.

sample

1
0 0
0

</p>