CF1168E.Xor Permutations
NOI/NOI+/CTSC
通过率:0%
时间限制:1.00s
内存限制:256MB
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.
蟾蜍米哈伊尔有一个长度为 2k 的整数数组 a1,a2,…,a2k。
请找出两个整数 0,1,…,2k−1 的排列 p 和 q,使得对所有可能的 i 均满足 ai=pi⊕qi;若不存在这样的排列,则判定其不存在。此处 ⊕ 表示按位异或运算。
输入格式
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.
第一行包含一个整数 k(2≤k≤12),表示数组的大小为 2k。
第二行包含 2k 个用空格分隔的整数 a1,a2,…,a2k(0≤ai<2k)—— 给定数组的元素。
输出格式
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.
如果给定数组无法表示为两个整数排列 0,1,…,2k−1 的按元素异或(XOR),则输出 "Fou"。
否则,在第一行输出 "Shi"。
接下来两行应分别描述两个满足条件的排列。第一行包含 2k 个以空格分隔的互异整数 p1,p2,…,p2k,第二行包含 2k 个以空格分隔的互异整数 q1,q2,…,q2k。
p 和 q 的所有元素均应在 0 到 2k−1(含端点)之间;且对所有满足 1≤i≤2k 的 i,需满足 pi⊕qi=ai。若存在多种可行解,输出任意一种即可。
输入输出样例
输入#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
输入解题思路,AI测评打分。不知道怎么写?