A10827 | Jon Snow and his Favourite Number
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 ) 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 , i.e. $7$ .
2. The strength of second ranger remains the same, i.e. $7$ .
3. The strength of third ranger is updated to , i.e. $11$ .
4. The strength of fourth ranger remains the same, i.e. $11$ .
5. 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?
1. Arrange all the rangers in a straight line in the order of increasing strengths.
2. 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: 1. The strength of first ranger is updated to , i.e. $7$ .
2. The strength of second ranger remains the same, i.e. $7$ .
3. The strength of third ranger is updated to , i.e. $11$ .
4. The strength of fourth ranger remains the same, i.e. $11$ .
5. 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?
输入格式
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}$ ).
Second line consists of $n$ integers representing the strengths of the rangers $a_{1},a_{2},...,a_{n}$ ( $0<=a_{i}<=10^{3}$ ).
输出格式
Output two integers, the maximum and the minimum strength of the rangers after performing the operation $k$ times.
输入输出样例
输入 #1
5 1 2 9 7 11 15 5
输出 #1
13 7
输入 #2
2 100000 569 605 986
输出 #2
986 605
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted