CF468B.Two Sets

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Little X has n distinct integers: _p_1, _p_2, ..., p__n. He wants to divide all of them into two sets A and B. The following two conditions must be satisfied:

  • If number x belongs to set A, then number a - x must also belong to set A.
  • If number x belongs to set B, then number b - x must also belong to set B.

Help Little X divide the numbers into two sets or determine that it's impossible.

小 X 有 nn 个互不相同的整数:p1, p2, …, pnp_1,\ p_2,\ \dots,\ p_n。他希望将所有这些数划分为两个集合 AA 和 BB,且必须满足以下两个条件:

  • 若数字 xx 属于集合 AA,则数字 a−xa - x 也必须属于集合 AA;
  • 若数字 xx 属于集合 BB,则数字 b−xb - x 也必须属于集合 BB。

请帮助小 X 将这些数划分为两个集合,或判断该划分不可能实现。

输入格式

The first line contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The next line contains n space-separated distinct integers _p_1, _p_2, ..., p__n (1 ≤ p__i ≤ 109).

第一行包含三个用空格分隔的整数 nn、aa、bb(1≤n≤1051 \leq n \leq 10^5;1≤a,b≤1091 \leq a, b \leq 10^9)。
下一行包含 nn 个用空格分隔的互不相同的整数 p1,p2,…,pnp_1, p_2, \dots, p_n(1≤pi≤1091 \leq p_i \leq 10^9)。

输出格式

If there is a way to divide the numbers into two sets, then print "YES" in the first line. Then print n integers: _b_1, _b_2, ..., b__n (b__i equals either 0, or 1), describing the division. If b__i equals to 0, then p__i belongs to set A, otherwise it belongs to set B.

If it's impossible, print "NO" (without the quotes).

如果存在一种将这些数划分为两个集合的方法,则在第一行输出 "YES"。然后输出 nn 个整数:b1, b2, …, bnb_1,\,b_2,\,\dots,\,b_n(每个 bib_i 的值为 00 或 11),用于描述该划分方案。若 bi=0b_i = 0,则 pip_i 属于集合 AA;否则 pip_i 属于集合 BB。

若不存在这样的划分方法,则输出 "NO"(不带引号)。

输入输出样例

  • 输入#1

    4 5 9
    2 3 4 5

    输出#1

    YES
    0 0 1 1
  • 输入#2

    3 3 4
    1 2 4

    输出#2

    NO

说明/提示

It's OK if all the numbers are in the same set, and the other one is empty.

如果所有数字都在同一个集合中,而另一个集合为空,这是允许的。

输入解题思路,AI测评打分。不知道怎么写?

首页