CF1849F.XOR Partition
省选/NOI-
通过率:0%
时间限制:7.00s
内存限制:512MB
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.
对于一组整数 S,定义其代价为该集合中所有不同整数对 (x,y) 的异或值 x⊕y 的最小值(其中 ⊕ 表示按位异或)。若集合中元素个数少于两个,则其代价定义为 230。
给定一组整数 {a1,a2,…,an}。你需要将它划分为两个集合 S1 和 S2,使得原集合中的每个元素恰好属于其中一个集合。该划分的值定义为 S1 与 S2 的代价中的较小者。
请找出使划分的值尽可能大的一种划分方案。
输入格式
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.
第一行包含一个整数 n(2≤n≤200000)—— 表示集合中元素的个数。
第二行包含 n 个互不相同的整数 a1, a2, ..., an(0≤ai<230)—— 表示集合中的元素。
输出格式
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.
输出一个长度为 n 的字符串,该字符串仅包含字符 0 和/或 1,用于描述划分方案:第 i 个字符应为 0,当且仅当元素 ai 属于集合 S1;否则,该字符应为 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测评打分。不知道怎么写?