CF1168E.Xor Permutations
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Toad Mikhail has an array of 2k integers a1,a2,…,a2k .
Find two permutations p and q of integers 0,1,…,2k−1 , such that ai is equal to pi⊕qi for all possible i , or determine there are no such permutations. Here ⊕ denotes the bitwise XOR operation.
输入格式
The first line contains one integer k ( 2≤k≤12 ), denoting that the size of the array is 2k .
The next line contains 2k space-separated integers a1,a2,…,a2k ( 0≤ai<2k ) — the elements of the given array.
输出格式
If the given array can't be represented as element-wise XOR of two permutations of integers 0,1,…,2k−1 , print "Fou".
Otherwise, print "Shi" in the first line.
The next two lines should contain the description of two suitable permutations. The first of these lines should contain 2k space-separated distinct integers p1,p2,…,p2k , and the second line should contain 2k space-separated distinct integers q1,q2,…,q2k .
All elements of p and q should be between 0 and 2k−1 , inclusive; pi⊕qi should be equal to ai for all i such that 1≤i≤2k . If there are several possible solutions, you can print any.
输入输出样例
输入#1
2 0 1 2 3
输出#1
Shi 2 0 1 3 2 1 3 0
输入#2
2 0 0 0 0
输出#2
Shi 0 1 2 3 0 1 2 3
输入#3
2 0 1 2 2
输出#3
Fou