CF1849F.XOR Partition

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

For a set of integers SS , let's define its cost as the minimum value of xyx \oplus y among all pairs of different integers from the set (here, \oplus denotes bitwise XOR). If there are less than two elements in the set, its cost is equal to 2302^{30} .

You are given a set of integers {a1,a2,,an}\{a_1, a_2, \dots, a_n\} . You have to partition it into two sets S1S_1 and S2S_2 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 S1S_1 and S2S_2 .

Find the partition with the maximum possible value.

输入格式

The first line contains nn ( 2n2000002 \le n \le 200000 ) — the number of elements in the set.

The second line contains nn distinct integers a1a_1 , a2a_2 , ..., ana_n ( 0ai<2300 \le a_i < 2^{30} ) — the elements of the set.

输出格式

Print a string nn characters 0 and/or 1 describing the partition as follows: the ii -th character should be 0 if the element aia_i belongs to S1S_1 , 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
首页