Universal Cup Judging System

Universal Cup

実行時間制限: 1.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓
統計
problem_15419_1.png

Traditional Gomoku, or five in a row, is played on a small board and ends immediately when five pieces of the same color are aligned. However, in "New Gomoku," the rules are different. The rules of New Gomoku are as follows:

  • The board is larger, with a length and width of $1000$.
  • Black and white players take turns placing their pieces, starting with the black player. A coordinate that has already been placed with a piece cannot be placed again.
  • If exactly $5$ pieces of the same color are arranged to form an unbroken line of five pieces (horizontally, vertically, or diagonally at $45^\circ/135^\circ$ to the horizontal line), it is called a set of five in a row. The game does not end when one side gets a set of five in a row.
  • The game ends when the predetermined number of moves is reached.

Your task is to output the total number of five in a row for the player who just placed their piece after each of the $n$ moves in the given sequence.

Input

There are multiple test cases in a single test file. The first line of the input contains a single integer $T$ ($1 \le T \le 10^4$), indicating the number of test cases.

For each test case:

  • The first line contains an integer $n$ ($1 \le n \le 10^4$), indicating the number of moves.
  • The next $n$ lines each contain two integers $x_i, y_i$ ($1 \le x_i, y_i \le 1000$) representing the coordinates of the $i$-th move, ensuring that all coordinates in the same data set are unique.

It is guaranteed that the total sum of $n$ over all test cases does not exceed $10^4$, i.e., $\sum n \le 10^4$.

Output

For each test case, output a single line with $n$ numbers, where the $i$-th number indicates the total number of five in a row for the player who just placed their piece after the $i$-th move.

Example

Sample 1

1
14
1 1
2 1
1 2
2 3
1 3
2 5
1 4
2 7
1 5
2 4
1 6
2 2
1 7
2 6
0 0 0 0 0 0 0 0 1 0 2 1 3 3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.