Divide by Zero 2017 and Codeforces Round 399 (Div. 1 + Div. 2, combined)
C
Jon Snow and his Favourite Number
Codeforces
1800
原题
← BD →
翻译中…

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:

翻译中…
  1. Arrange all the rangers in a straight line in the order of increasing strengths.
  2. Take the bitwise XOR (is written as image) 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:

翻译中…
  1. The strength of first ranger is updated to image, i.e. $7$.
  2. The strength of second ranger remains the same, i.e. $7$.
  3. The strength of third ranger is updated to image, i.e. $11$.
  4. The strength of fourth ranger remains the same, i.e. $11$.
  5. The strength of fifth ranger is updated to image, 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?

翻译中…

Input

翻译中…

First line consists of three integers $*n*$, $*k*$, $*x*$ ($1 ≤ *n* ≤ 10^{5}$, $0 ≤ *k* ≤ 10^{5}$, $0 ≤ *x* ≤ 10^{3}$) — 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*} ≤ 10^{3}$).

翻译中…

Output

翻译中…

Output two integers, the maximum and the minimum strength of the rangers after performing the operation $*k*$ times.

翻译中…

样例

Input #1
5 1 2
9 7 11 15 5
Output #1
13 7
InputCopy OutputCopy
Input #2
2 100000 569
605 986
Output #2
986 605
InputCopy OutputCopy
题目信息
题号
768C
时间限制
4 s
内存限制
256 MB
标签
暴力
动态规划
模拟
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。