Universal Cup Judging System

Universal Cup

実行時間制限: 2 s メモリ制限: 1024 MB 満点: 100 難易度: [表示]
統計

There are $n$ Mahou Shoujo sitting in a circle, numbered clockwise from 1 to $n$. Among them, some are actually Majo. For the next $n-3$ days, the following events occur one by one: In the night, exactly one Majo wakes up and kills the first living Mahou Shoujo on her left or right (this person could also be a Majo). In the morning, everyone wakes up and discovers the dead Mahou Shoujo.

Kamome, as the judge of the Mahou Shoujo, needs to find, after each morning when a dead Mahou Shoujo is discovered, the minimum number of Majo that could have been present on the first day.

Picture 1: The Judgement

输入格式

Each test contains multiple test cases. The first line contains one integer $t$ ($1 \le t \le 10^5$), indicating the number of test cases. The description of the test cases follows.

The first line contains two integers $n$ ($4 \le n \le 2 \times 10^5$, $1 < \sum n \le 10^6$), indicating the number of Mahou Shoujo. The second line contains $n-3$ integers $p_i$ ($1 \le p_i \le n$), indicating the Mahou Shoujo who died on the $i$-th day.

输出格式

For each test case, output one line containing $n-3$ integers, indicating the minimum number of Majo that could have been present on the first day after discovering the dead Mahou Shoujo on the $i$-th day.

样例

输入 1

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

输出 1

1 1 1 1 1
1 1 2 2 3 3 3
1 2 2 3 3 3 3

说明

For the second test case, on the third day, at least 2 Majo could have been present on the first day. A possible example is 3 and 4 being the Majo, where 3 kills 2 on the first day, 3 kills 1 on the second day, and 4 kills 3 on the third day.

Picture 2: A possible example

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.