CF303A.Lucky Permutation Triple

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Bike is interested in permutations. A permutation of length n is an integer sequence such that each integer from 0 to (n - 1) appears exactly once in it. For example, [0, 2, 1] is a permutation of length 3 while both [0, 2, 2] and [1, 2, 3] is not.

A permutation triple of permutations of length n (a, b, c) is called a Lucky Permutation Triple if and only if . The sign a__i denotes the i-th element of permutation a. The modular equality described above denotes that the remainders after dividing a__i + b__i by n and dividing c__i by n are equal.

Now, he has an integer n and wants to find a Lucky Permutation Triple. Could you please help him?

Bike 对排列很感兴趣。长度为 nn 的排列是一个整数序列,其中每个从 00 到 n−1n-1 的整数恰好出现一次。例如,[0, 2, 1][0,\,2,\,1] 是一个长度为 33 的排列,而 [0, 2, 2][0,\,2,\,2] 和 [1, 2, 3][1,\,2,\,3] 都不是。

一个长度为 nn 的排列三元组 (a, b, c)(a,\,b,\,c) 被称为幸运排列三元组,当且仅当
。
符号 aia_i 表示排列 aa 的第 ii 个元素。上述模等式表示:ai+bia_i + b_i 除以 nn 的余数等于 cic_i 除以 nn 的余数。

现在,他给定一个整数 nn,希望找出一个幸运排列三元组。你能帮他实现吗?

输入格式

The first line contains a single integer n (1 ≤ n ≤ 105).

第一行包含一个整数 nn(1≤n≤1051 \leq n \leq 10^5)。

输出格式

If no Lucky Permutation Triple of length n exists print -1.

Otherwise, you need to print three lines. Each line contains n space-seperated integers. The first line must contain permutation a, the second line — permutation b, the third — permutation c.

If there are multiple solutions, print any of them.

如果不存在长度为 nn 的幸运排列三元组,则输出 -1。

否则,你需要输出三行,每行包含 nn 个以空格分隔的整数:第一行为排列 aa,第二行为排列 bb,第三行为排列 cc。

若存在多种解,输出任意一种即可。

输入输出样例

  • 输入#1

    5

    输出#1

    1 4 3 2 0
    1 0 2 4 3
    2 4 0 1 3
  • 输入#2

    2

    输出#2

    -1

说明/提示

In Sample 1, the permutation triple ([1, 4, 3, 2, 0], [1, 0, 2, 4, 3], [2, 4, 0, 1, 3]) is Lucky Permutation Triple, as following holds:

  • ;
  • ;
  • ;
  • ;
  • .

In Sample 2, you can easily notice that no lucky permutation triple exists.

在样例 1 中,排列三元组 ([1, 4, 3, 2, 0], [1, 0, 2, 4, 3], [2, 4, 0, 1, 3])([1,\,4,\,3,\,2,\,0],\,[1,\,0,\,2,\,4,\,3],\,[2,\,4,\,0,\,1,\,3]) 是一个幸运排列三元组,因为以下等式成立:

  • ;
  • ;
  • ;
  • ;
  • .

在样例 2 中,你可以很容易地注意到:不存在幸运排列三元组。

输入解题思路,AI测评打分。不知道怎么写?

首页