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 有 n 个互不相同的整数:p1, p2, …, pn。他希望将所有这些数划分为两个集合 A 和 B,且必须满足以下两个条件:
- 若数字 x 属于集合 A,则数字 a−x 也必须属于集合 A;
- 若数字 x 属于集合 B,则数字 b−x 也必须属于集合 B。
请帮助小 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).
第一行包含三个用空格分隔的整数 n、a、b(1≤n≤105;1≤a,b≤109)。
下一行包含 n 个用空格分隔的互不相同的整数 p1,p2,…,pn(1≤pi≤109)。
输出格式
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"。然后输出 n 个整数:b1,b2,…,bn(每个 bi 的值为 0 或 1),用于描述该划分方案。若 bi=0,则 pi 属于集合 A;否则 pi 属于集合 B。
若不存在这样的划分方法,则输出 "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测评打分。不知道怎么写?