|
||||||||||
Find PermutationTime 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
Sample Output
Source | ||||||||||
|