CF1849F.XOR Partition
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For a set of integers S , let's define its cost as the minimum value of x⊕y among all pairs of different integers from the set (here, ⊕ denotes bitwise XOR). If there are less than two elements in the set, its cost is equal to 230 .
You are given a set of integers {a1,a2,…,an} . You have to partition it into two sets S1 and S2 in such a way that every element of the given set belongs to exactly one of these two sets. The value of the partition is the minimum among the costs of S1 and S2 .
Find the partition with the maximum possible value.
输入格式
The first line contains n ( 2≤n≤200000 ) — the number of elements in the set.
The second line contains n distinct integers a1 , a2 , ..., an ( 0≤ai<230 ) — the elements of the set.
输出格式
Print a string n characters 0 and/or 1 describing the partition as follows: the i -th character should be 0 if the element ai belongs to S1 , otherwise, that character should be 1.
If there are multiple optimal answers, print any of them.
输入输出样例
输入#1
5 42 13 1337 37 152
输出#1
10001
输入#2
4 1 2 3 4
输出#2
1100
输入#3
2 1 2
输出#3
10
输入#4
8 7 6 5 4 3 2 1 0
输出#4
10010110