CF1417B.Two Arrays

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

RedDreamer has an array aa consisting of nn non-negative integers, and an unlucky integer TT .

Let's denote the misfortune of array bb having length mm as f(b)f(b) — the number of pairs of integers (i,j)(i, j) such that 1i<jm1 \le i < j \le m and bi+bj=Tb_i + b_j = T . RedDreamer has to paint each element of aa into one of two colors, white and black (for each element, the color is chosen independently), and then create two arrays cc and dd so that all white elements belong to cc , and all black elements belong to dd (it is possible that one of these two arrays becomes empty). RedDreamer wants to paint the elements in such a way that f(c)+f(d)f(c) + f(d) is minimum possible.

For example:

  • if n=6n = 6 , T=7T = 7 and a=[1,2,3,4,5,6]a = [1, 2, 3, 4, 5, 6] , it is possible to paint the 11 -st, the 44 -th and the 55 -th elements white, and all other elements black. So c=[1,4,5]c = [1, 4, 5] , d=[2,3,6]d = [2, 3, 6] , and f(c)+f(d)=0+0=0f(c) + f(d) = 0 + 0 = 0 ;
  • if n=3n = 3 , T=6T = 6 and a=[3,3,3]a = [3, 3, 3] , it is possible to paint the 11 -st element white, and all other elements black. So c=[3]c = [3] , d=[3,3]d = [3, 3] , and f(c)+f(d)=0+1=1f(c) + f(d) = 0 + 1 = 1 .

Help RedDreamer to paint the array optimally!

输入格式

The first line contains one integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases. Then tt test cases follow.

The first line of each test case contains two integers nn and TT ( 1n1051 \le n \le 10^5 , 0T1090 \le T \le 10^9 ) — the number of elements in the array and the unlucky integer, respectively.

The second line contains nn integers a1a_1 , a2a_2 , ..., ana_n ( 0ai1090 \le a_i \le 10^9 ) — the elements of the array.

The sum of nn over all test cases does not exceed 10510^5 .

输出格式

For each test case print nn integers: p1p_1 , p2p_2 , ..., pnp_n (each pip_i is either 00 or 11 ) denoting the colors. If pip_i is 00 , then aia_i is white and belongs to the array cc , otherwise it is black and belongs to the array dd .

If there are multiple answers that minimize the value of f(c)+f(d)f(c) + f(d) , print any of them.

输入输出样例

  • 输入#1

    2
    6 7
    1 2 3 4 5 6
    3 6
    3 3 3

    输出#1

    1 0 0 1 1 0 
    1 0 0
首页