CF1849F.XOR Partition

省选/NOI-

通过率:0%

时间限制:7.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

For a set of integers SS, let's define its cost as the minimum value of x⊕yx \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.

对于一组整数 SS,定义其代价为该集合中所有不同整数对 (x,y)(x, y) 的异或值 x⊕yx \oplus y 的最小值(其中 ⊕\oplus 表示按位异或)。若集合中元素个数少于两个,则其代价定义为 2302^{30}。

给定一组整数 {a1,a2,…,an}\{a_1, a_2, \dots, a_n\}。你需要将它划分为两个集合 S1S_1 和 S2S_2,使得原集合中的每个元素恰好属于其中一个集合。该划分的值定义为 S1S_1 与 S2S_2 的代价中的较小者。

请找出使划分的值尽可能大的一种划分方案。

输入格式

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

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

第一行包含一个整数 nn(2≤n≤2000002 \le n \le 200000)—— 表示集合中元素的个数。

第二行包含 nn 个互不相同的整数 a1a_1, a2a_2, ..., ana_n(0≤ai<2300 \le a_i \lt 2^{30})—— 表示集合中的元素。

输出格式

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.

输出一个长度为 nn 的字符串,该字符串仅包含字符 0 和/或 1,用于描述划分方案:第 ii 个字符应为 0,当且仅当元素 aia_i 属于集合 S1S_1;否则,该字符应为 1。

若存在多个最优解,输出其中任意一个即可。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页