欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1417B.Two Arrays
Two Arrays
RedDreamer has an array consisting of non-negative integers, and an unlucky integer .
Let's denote the misfortune of array having length as — the number of pairs of integers such that and . RedDreamer has to paint each element of into one of two colors, white and black (for each element, the color is chosen independently), and then create two arrays and so that all white elements belong to , and all black elements belong to (it is possible that one of these two arrays becomes empty). RedDreamer wants to paint the elements in such a way that is minimum possible.
For example:
- if , and , it is possible to paint the -st, the -th and the -th elements white, and all other elements black. So , , and ;
- if , and , it is possible to paint the -st element white, and all other elements black. So , , and .
Help RedDreamer to paint the array optimally!
Input
The first line contains one integer () — the number of test cases. Then test cases follow.
The first line of each test case contains two integers and (, ) — the number of elements in the array and the unlucky integer, respectively.
The second line contains integers , , ..., () — the elements of the array.
The sum of over all test cases does not exceed .
Output
For each test case print integers: , , ..., (each is either or ) denoting the colors. If is , then is white and belongs to the array , otherwise it is black and belongs to the array .
If there are multiple answers that minimize the value of , print any of them.
Samples
2
6 7
1 2 3 4 5 6
3 6
3 3 3
1 0 0 1 1 0
1 0 0
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |