#P9723. [EC Final 2022] Chinese Checker

    ID: 9045 Type: RemoteJudge 1000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>2022O2优化广度优先搜索,BFSICPC

[EC Final 2022] Chinese Checker

题目描述

Prof. Pang is playing Chinese Checkers. The game board is the same as the figure shown above. There are nn checkers on the board. Prof. Pang wants to know how many different moves there are on the current board.

One move consists of several steps. At first, Prof. Pang needs to choose one checker aa to move. In each step, Prof. Pang needs to choose another checker bb as the pivot, and move the checker aa to the symmetrical position about the checker bb. (In one move, Prof. Pang cannot change his choice of aa between steps. If after a step, the checker aa will return to its position before the move, this step is not allowed.) There are several conditions about the pivot bb:

  • The segment connecting aa and bb needs to be parallel to one of the coordinate axis. Note: There are three axes on the hexagonal board. One of them is horizontal and any pair of axes intersect at an angle of π/3\pi/3.
  • aa and bb do not need to be adjacent.
  • There cannot be extra checkers other than bb on the segment connecting aa and its symmetrical position.
  • The symmetrical position should be on the hexagonal board and is not occupied by any other checker.

A move must have at least one step. After the first step, Prof. Pang can stop at any time he wants. And Prof. Pang can choose any checker on the board as the moving checker. Output the number of different moves Prof. Pang can make. Two moves are different if and only if the sets of positions of all checkers are different after these two moves, i.e., the checkers are indistinguishable.

输入格式

The first line contains an integer T (1T100)T~(1\leq T\leq 100) -- the number of test cases.

For each test case, the first line contains an integer n (1n121)n~(1\leq n\leq 121) -- the number of checkers.

Each of the following nn lines contains two integers, indicating the position of a checker. The first number indicates which row it is in, and the second number indicates which one of this row it is. They are counting from top to bottom and left to right, starting from 11.

It is guaranteed that checkers' positions are different.

输出格式

For each test case, output one integer in a line -- the number of different moves.

5
1
1 1
2
1 1
2 1
2
9 4
9 6
10
1 1
2 1
2 2
3 1
3 2
3 3
4 1
4 2
4 3
4 4
10
1 1
2 1
2 2
5 7
3 2
3 3
4 1
4 2
4 3
4 4

0
1
2
6
13