CF1168E.Xor Permutations

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Toad Mikhail has an array of 2k2^k integers a1,a2,,a2ka_1, a_2, \ldots, a_{2^k} .

Find two permutations pp and qq of integers 0,1,,2k10, 1, \ldots, 2^k-1 , such that aia_i is equal to piqip_i \oplus q_i for all possible ii , or determine there are no such permutations. Here \oplus denotes the bitwise XOR operation.

输入格式

The first line contains one integer kk ( 2k122 \leq k \leq 12 ), denoting that the size of the array is 2k2^k .

The next line contains 2k2^k space-separated integers a1,a2,,a2ka_1, a_2, \ldots, a_{2^k} ( 0ai<2k0 \leq a_i < 2^k ) — 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,,2k10, 1, \ldots, 2^k-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 2k2^k space-separated distinct integers p1,p2,,p2kp_{1}, p_{2}, \ldots, p_{2^k} , and the second line should contain 2k2^k space-separated distinct integers q1,q2,,q2kq_{1}, q_{2}, \ldots, q_{2^k} .

All elements of pp and qq should be between 00 and 2k12^k - 1 , inclusive; piqip_i \oplus q_i should be equal to aia_i for all ii such that 1i2k1 \leq i \leq 2^k . 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
    
首页