Checker for Array Shuffling solution codeforces
oolimry has an arrayof length which he really likes. Today, you have changed his array to , a permutation of , to make him sad.
Because oolimry is only a duck, he can only perform the following operation to restore his array:
- Choose two integers such that .
- Swap and .
The sadness of the array is the minimum number of operations needed to transform into .
Given the arraysand , where is a permutation of , determine if has the maximum sadness over all permutations of .
Each test contains multiple test cases. The first line contains a single integer( ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer( ) — the length of the array.
The second line of each test case containsintegers ( ) — the elements of the array .
The third line of each test case containsintegers ( ) — the elements of the array .
It is guaranteed thatis a permutation of .
It is guaranteed that the sum ofover all test cases does not exceed .
For each test case, print “AC” (without quotes) if has the maximum sadness over all permutations of , and “WA” (without quotes) otherwise.
4 2 2 1 1 2 4 1 2 3 3 3 3 2 1 2 2 1 2 1 4 1 2 3 3 3 2 3 1
AC AC WA WA
In the first test case, the arrayhas sadness . We can transform into using one operation with .
In the second test case, the arrayhas sadness . We can transform into with two operations with and respectively.
In the third test case, the arrayhas sadness .
In the fourth test case, the arrayhas sadness .
I am the Founder and the creator of the blog neoideasblog.com where we share latest trivia questions and answers on a daily basis.