c语言sscanf函数的用法是什么
281
2022-09-14
Codeforces 268 B - Two Sets 搜索...
题意:
n distinct integers: p1, p2, ..., pn. He wants to divide all of them into two sets A and B. The following two conditions must be satisfied:
xbelongs to setA, then numbera-xmust also belong to setA.xbelongs to setB, then numberb-xmust also belong to setB.
Help Little X divide the numbers into two sets or determine that it's impossible.
Input
n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The next line contains n space-separated distinct integers p1, p2, ..., pn (1 ≤ pi ≤ 109).
Output
YES" in the first line. Then print n integers: b1, b2, ..., bn (bi equals either 0, or 1), describing the division. If bi equals to 0, then pi belongs to set A, otherwise it belongs to set B.
NO" (without the quotes).
题解:
因为一个数要么A要么属于B..那么将它们都先定为A..再把不符合的调整到B..由于改变了一个位置从A到B..会让若干的数也会变..用一个dfs来处理就好...
Program:
#include
发表评论
暂时没有评论,来抢沙发吧~