CF768C.Jon Snow and his Favourite Number
普及+/提高
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times:
- Arrange all the rangers in a straight line in the order of increasing strengths.
- Take the bitwise XOR (is written as
) of the strength of each alternate ranger with x and update it's strength.
Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following:
- The strength of first ranger is updated to
, i.e. 7. - The strength of second ranger remains the same, i.e. 7.
- The strength of third ranger is updated to
, i.e. 11. - The strength of fourth ranger remains the same, i.e. 11.
- The strength of fifth ranger is updated to
, i.e. 13.
The new strengths of the 5 rangers are [7, 7, 11, 11, 13]
Now, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?
琼·雪诺现在必须与异鬼作战。他有 n 名守夜人,每名守夜人都有自己的力量值。此外,琼·雪诺还有一个他最钟爱的数字 x。每位守夜人仅当异鬼的力量值恰好等于他自身的力量值时,才能与之作战。然而,他认为自己的守夜人实力较弱,需要提升。琼·雪诺想到:如果将部分守夜人的力量值与其最钟爱的数字 x 进行按位异或(XOR)运算,或许就能获得更强大的战士。因此,他决定执行以下操作共 k 次:
- 将所有守夜人按力量值升序排列成一条直线;
- 对每隔一位的守夜人的力量值与 x 进行按位异或(
)运算,并用该结果更新其力量值。
例如,假设琼有 5 名守夜人,力量值为 [9,7,11,15,5],并以 x=2 执行 1 次该操作。他首先将他们按力量值升序排列为 [5,7,9,11,15],然后执行如下步骤:
- 第一名守夜人的力量值更新为
,即 7; - 第二名守夜人的力量值保持不变,仍为 7;
- 第三名守夜人的力量值更新为
,即 11; - 第四名守夜人的力量值保持不变,仍为 11;
- 第五名守夜人的力量值更新为
,即 13。
于是,5 名守夜人的新力量值为 [7,7,11,11,13]。
现在,琼·雪诺希望知道:在执行上述操作 k 次后,守夜人中力量值的最大值与最小值分别是多少?他需要你协助完成这项任务。你能帮他吗?
输入格式
First line consists of three integers n, k, x (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.
Second line consists of n integers representing the strengths of the rangers _a_1, _a_2, ..., a__n (0 ≤ a__i ≤ 103).
第一行包含三个整数 n、k、x(1 ≤ n ≤ 105,0 ≤ k ≤ 105,0 ≤ x ≤ 103),分别表示 Jon 拥有的游侠数量、Jon 将执行操作的次数以及 Jon 最喜欢的数字。
第二行包含 n 个整数,表示游侠们的实力值 a1,a2,...,an(0 ≤ ai ≤ 103)。
输出格式
Output two integers, the maximum and the minimum strength of the rangers after performing the operation k times.
输出两个整数,分别表示执行操作 k 次后游侠们的最大和最小战力。
输入输出样例
输入#1
5 1 2 9 7 11 15 5
输出#1
13 7
输入#2
2 100000 569 605 986
输出#2
986 605
输入解题思路,AI测评打分。不知道怎么写?