#P8880. 无知时诋毁原神

无知时诋毁原神

Background

Nahida really likes permutations.

Artist pid: 72405030

Problem Description

Nahida has a permutation cc of 0n10 \sim n-1. She wants you to construct two permutations a,ba, b, also of 0n10 \sim n-1, such that i[1,n]\forall i \in [1,n], ci=(ai+bi)modnc_i = (a_i + b_i) \bmod n. If Nahida's requirement cannot be satisfied, output 1-1.

Input Format

The first line contains an integer nn.

The second line contains nn integers, representing the permutation cc.

Output Format

If there is no construction that meets the requirements, output one line with 1-1.

Otherwise, output two lines, each with nn integers. The first line is aia_i, and the second line is bib_i.

3
2 1 0
2 0 1
0 1 2
4
1 3 0 2
-1

Hint

Constraints

  • Subtask 1(30 pts)\text{Subtask 1(30 pts)}: n10n \le 10.
  • Subtask 2(20 pts)\text{Subtask 2(20 pts)}: A solution is guaranteed to exist.
  • Subtask 3(50 pts)\text{Subtask 3(50 pts)}: No special properties.

For 100%100\% of the testdata, it is guaranteed that 1n1051 \le n \le 10^5, and cc is a permutation.

Translated by ChatGPT 5