Universal Cup Judging System

Universal Cup

時間限制: 2 s 記憶體限制: 1024 MB 總分: 100 难度: [顯示]
统计

$n$ 人の魔法少女が円形に座っており, 時計回りに 1 から $n$ まで番号が付けられている. その中には, 実際には魔女である者もいる.

その後, $n-3$ 日間にわたって, 以下の出来事が 1 つずつ起こる:

  • 夜に, ちょうど 1 人の魔女が目覚め, その左側または右側で最初に生きている魔法少女 (この人物も魔女である可能性がある) を殺す.
  • 朝に, 全員が目覚め, 殺された魔法少女を発見する.

魔法少女たちの審判役である Kamome は, 殺された魔法少女が発見される各朝の後, 初日に存在していた可能性のある魔女の最小人数を見つける必要がある.

図1: 審判

入力

各テストケースは複数のテストケースからなる. 1 行目には整数 $t$ ($1 \le t \le 10^5$) が含まれ, テストケースの数を示す. 続けてテストケースの説明が与えられる.

各テストケースの 1 行目には 2 つの整数 $n$ ($4 \le n \le 2 \times 10^5$, $1 < \sum n \le 10^6$) が含まれ, 魔法少女の数を示す.

2 行目には $n-3$ 個の整数 $p_i$ ($1 \le p_i \le n$, $1 < i < j < n-3$ に対して $p_i \ne p_j$) が含まれ, $i$ 日目に死んだ魔法少女を示す.

出力

各テストケースについて, $n-3$ 個の整数を含む 1 行を出力せよ. これらは, $i$ 日目に殺された魔法少女が発見された後に, 初日に存在していた可能性のある魔女の最小人数を示す.

入出力例

入力 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

注記

2 番目のテストケースについて, 3 日目には, 初日に少なくとも 2 人の魔女が存在していた可能性がある. 可能な例の 1 つは, 3 と 4 が魔女であり, 1 日目に 3 が 2 を殺し, 2 日目に 3 が 1 を殺し, 3 日目に 4 が 3 を殺す.

図2: 可能な例

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.