B - Three Mex 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 500 点

問題文

非負整数 A, B, C が与えられます.以下の 3 つの条件を満たす非負整数集合 X, Y が存在するか判定し,存在する場合はその一例を示してください.

  • X, Y の各要素は 2026 以下の非負整数である.
  • \mathrm{mex}(X)=A, \mathrm{mex}(Y)=B である.
  • 非負整数集合 Z を Z=\{x\oplus y\mid x\in X, y \in Y\} で定める.このとき,\mathrm{mex}(Z)=C である.ただしここで,\oplus はビット単位 \mathrm{XOR} 演算を表します.
\mathrm{mex}(S) とは 非負整数からなる有限集合 S に対し,s\notin S を満たす最小の非負整数 s を \mathrm{mex}(S) と定義します.
ビット単位 \mathrm{XOR} 演算とは

非負整数 x, y のビット単位 \mathrm{XOR},x \oplus y は,以下のように定義されます.

  • x \oplus y を二進表記した際の 2^k (k \geq 0) の位の数は,x, y を二進表記した際の 2^k の位の数のうち一方のみが 1 であれば 1,そうでなければ 0 である.
例えば,3 \oplus 5 = 6 となります (二進表記すると: 011 \oplus 101 = 110).

1 つの入力ファイルにつき,T 個のテストケースを解いてください.

制約

  • 1 \leq T \leq 10
  • 0 \leq A \leq 1000
  • 0 \leq B \leq 1000
  • 0 \leq C \leq 1000
  • 入力される値はすべて整数である

入力

入力は以下の形式で標準入力から与えられる.ここで,\mathrm{case}_i (1 \leq i \leq T) は i 番目のテストケースを意味する.

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T

各テストケースは以下の形式で与えられる.

A B C

出力

\mathrm{case}_1, \mathrm{case}_2, \cdots, \mathrm{case}_T の順に答えを出力せよ.それぞれのテストケースにおいては,以下のように出力せよ.

  • 条件を満たす非負整数集合 X, Y が存在しない場合,No を出力して,改行せよ.
  • 条件を満たす非負整数集合 X, Y が存在する場合,その一例を以下の形式で出力せよ.X, Y の要素数をそれぞれ N, M とし,X の i 番目 (1 \leq i \leq N) の要素を X_i,Y の j 番目 (1 \leq j \leq M) の要素を Y_j とする.ここで,X_1, X_2, \cdots, X_N は相異なる必要がある.また,Y_1, Y_2, \cdots, Y_M も相異なる必要がある.条件を満たす非負整数集合 X, Y が複数存在する場合,いずれを出力しても正解と判定される.
Yes
N X_1 X_2 \cdots X_N
M Y_1 Y_2 \cdots Y_M

入力例 1

4
2 3 6
1 1 0
0 0 1
0 0 0

出力例 1

Yes
3 0 1 3
4 0 1 2 4
No
Yes
1 1
1 1
Yes
0
3 2026 10 4
  • 1 番目のテストケースについて,X = \{ 0, 1, 3 \}, Y = \{ 0, 1, 2, 4 \} より Z = \{0, 1, 2, 3, 4, 5, 7 \} となり,\mathrm{mex}(X) = 2, \mathrm{mex}(Y) = 3, \mathrm{mex}(Z) = 6 が満たされます.
  • 2 番目のテストケースについて,条件を満たす非負整数集合 X, Y は存在しません.
  • 4 番目のテストケースについて,X, Y は空集合としても構いません.

Score : 500 points

Problem Statement

You are given non-negative integers A, B, C. Determine whether there exist sets of non-negative integers X, Y satisfying the following three conditions, and if they exist, show one example.

  • Each element of X, Y is a non-negative integer at most 2026.
  • \mathrm{mex}(X)=A, \mathrm{mex}(Y)=B.
  • Define the set of non-negative integers Z as Z=\{x\oplus y\mid x\in X, y \in Y\}. Then, \mathrm{mex}(Z)=C. Here, \oplus denotes the bitwise \mathrm{XOR} operation.
What is \mathrm{mex}(S)? For a finite set S of non-negative integers, \mathrm{mex}(S) is defined as the smallest non-negative integer s satisfying s\notin S.
What is the bitwise \mathrm{XOR} operation?

The bitwise \mathrm{XOR} of non-negative integers x and y, x \oplus y, is defined as follows.

  • When x \oplus y is written in binary, the digit in the 2^k (k \geq 0) place is 1 if exactly one of the digits in the 2^k place of x and y written in binary is 1, and 0 otherwise.
For example, 3 \oplus 5 = 6 (in binary: 011 \oplus 101 = 110).

Solve T test cases per input file.

Constraints

  • 1 \leq T \leq 10
  • 0 \leq A \leq 1000
  • 0 \leq B \leq 1000
  • 0 \leq C \leq 1000
  • All input values are integers.

Input

The input is given from Standard Input in the following format. Here, \mathrm{case}_i (1 \leq i \leq T) denotes the i-th test case.

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T

Each test case is given in the following format:

A B C

Output

Output the answers in the order \mathrm{case}_1, \mathrm{case}_2, \cdots, \mathrm{case}_T. For each test case, output as follows.

  • If there do not exist sets of non-negative integers X, Y satisfying the conditions, output No followed by a newline.
  • If there exist sets of non-negative integers X, Y satisfying the conditions, output one example in the following format. Let N, M be the numbers of elements of X, Y, respectively, let X_i be the i-th element (1 \leq i \leq N) of X, and let Y_j be the j-th element (1 \leq j \leq M) of Y. Here, X_1, X_2, \cdots, X_N must be pairwise distinct. Also, Y_1, Y_2, \cdots, Y_M must be pairwise distinct. If there are multiple pairs of sets of non-negative integers X, Y satisfying the conditions, any of them will be judged as correct.
Yes
N X_1 X_2 \cdots X_N
M Y_1 Y_2 \cdots Y_M

Sample Input 1

4
2 3 6
1 1 0
0 0 1
0 0 0

Sample Output 1

Yes
3 0 1 3
4 0 1 2 4
No
Yes
1 1
1 1
Yes
0
3 2026 10 4
  • For the first test case, since X = \{ 0, 1, 3 \}, Y = \{ 0, 1, 2, 4 \}, we have Z = \{0, 1, 2, 3, 4, 5, 7 \}, which satisfies \mathrm{mex}(X) = 2, \mathrm{mex}(Y) = 3, \mathrm{mex}(Z) = 6.
  • For the second test case, there do not exist sets of non-negative integers X, Y satisfying the conditions.
  • For the fourth test case, X, Y may be empty sets.