Universal Cup Judging System

Universal Cup

시간 제한: 2.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓
통계

題目描述

俾定一個整數 $N$。請判斷是否存在一個由 $(1, 2, \dots, N)$ 重新排列而成、且滿足以下條件嘅數列 $P = (p_1, p_2, \dots, p_N)$;如果存在,請構造出其中一個。

喺度,滿足 $1 \le i < j < k \le N$ 嘅整數三元組 $(i, j, k)$ 稱為好下標三元組。

  • 滿足 $p_i < p_j < p_k$ 嘅好下標三元組 $(i, j, k)$ 嘅數量,等於滿足 $p_i > p_j > p_k$ 嘅好下標三元組 $(i, j, k)$ 嘅數量。

如果唔存在滿足條件嘅數列,請輸出 $-1$。

題目會俾出 $T$ 組測試數據,請分別求解每一組。

輸入格式

輸入由標準輸入按以下格式給出:

T
case_1
case_2
:
case_T

每組測試數據按以下格式給出:

N

數據範圍

  • $1 \le T \le 5 \times 10^5$
  • $3 \le N \le 5 \times 10^5$
  • 所有測試數據嘅 $N$ 之和唔超過 $5 \times 10^5$。
  • 輸入嘅所有數值都係整數。

輸出格式

對於每組測試數據,如果唔存在滿足條件嘅數列,請輸出 $-1$;否則請喺同一行輸出 $N$ 個以空格分隔嘅整數,代表滿足條件嘅數列 $P$。如果有多個滿足條件嘅數列,輸出任意一個即可。

範例

範例輸入1

2
3
4

範例輸出1

1 3 2
2 4 1 3

範例解釋

範例 1 解釋

當 $N = 3$ 時,我哋驗證 $(1, 3, 2)$ 滿足條件。好下標三元組只有 $(1, 2, 3)$。喺 $(1, 3, 2)$ 入面,滿足前者嘅好下標三元組有 $0$ 個,滿足後者嘅好下標三元組亦有 $0$ 個。兩者數量相等,因此呢個數列滿足條件。

當 $N = 4$ 時,我哋驗證 $(2, 4, 1, 3)$ 滿足條件。好下標三元組有以下四個:

$$(1, 2, 3), \ (1, 2, 4), \ (1, 3, 4), \ (2, 3, 4)$$

無論係前者定係後者,都冇任何好下標三元組滿足,所以數量都係 $0$ 個。兩者數量相等,因此呢個數列滿足條件。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#2545EditorialOpen题解KobicGendView
#1495EditorialOpen题解jianglyView
#1347EditorialOpen题解MilmonView

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.