2183: Find Permutation
内存限制:128 MB
时间限制:1.000 S
评测方式:文本比较
命题人:
提交:8
解决:2
题目描述
Given b0, b1, ..., bn-1, find two permutations {ai}, {ci} of 0..n-1 such that ai+bi=ci (mod n) for every i.
输入
First line, number of test cases, T.
Following are 2*T. For every two lines, the first line is n and the second line contains n integers.
Sum of all n <= 105.
0<=bi<n
It's guaranteed that there exists a solution.
Test data is generated by randomly choosing two permutations and subtracting one from the other.
输出
2*T lines. Every line contains n integers. For every two lines, the first line represents {ai} and the second line represents {ci}.
If there are multiple solutions, output any one of them.
样例输入 复制
1
3
0 1 2
样例输出 复制
2 0 1
2 1 0