F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Find Permutation

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 370    Accepted Submission(s): 123
Special Judge


Problem Description
Given b0, b1, ..., bn-1, find two permutations {ai}, {ci} of 0..n-1 such that ai+bi=ci (mod n) for every i.
 

Input
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.
 

Output
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.
 

Sample Input
1 3 0 1 2
 

Sample Output
2 0 1 2 1 0
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-25 05:14:38, Gzip enabled