

Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 500 点
問題文
X 個の 0、Y 個の 1、Z 個の 2 からなる長さ X+Y+Z の非負整数列 A=(A_1,A_2,\dots,A_{X+Y+Z}) であって、以下の条件を満たすものが存在するか判定してください。
- 全ての i(1 \le i \le X+Y+Z) に対して、A_{i-1},A_{i+1} のうち A_i 未満のものはちょうど A_i 個である。
ただし、A_0 = A_{X+Y+Z},A_{X+Y+Z+1} = A_1 とします。
T 個のテストケースが与えられるので、それぞれについて答えを求めてください。
制約
- 1 \le T \le 2 \times 10^5
- 0 \le X,Y,Z \le 10^9
- 3 \le X + Y + Z
入力
入力は以下の形式で標準入力から与えられる。
T \mathrm{case}_1 \mathrm{case}_2 \vdots \mathrm{case}_T
各ケースは以下の形式で与えられる。
X\ Y\ Z
出力
T 行出力せよ。i(1 \le i \le T) 行目には、i 個目のテストケースにおいて条件を満たすものが存在するなら Yes
を、そうでないならば No
を出力せよ。
入力例 1
4 2 1 1 3 4 5 1359 1998 1022 392848293 683919483 822948689
出力例 1
Yes No Yes No
1 個目のテストケースについて、A = (2,0,0,1) とすると条件を満たします。
2 個目のテストケースについて、条件を満たす数列は存在しません。
Score : 500 points
Problem Statement
Determine whether there exists a sequence A=(A_1,A_2,\dots,A_{X+Y+Z}) of length X+Y+Z that contains exactly X zeros, Y ones, and Z twos, and satisfies the following condition:
- For every i(1 \le i \le X+Y+Z), exactly A_i numbers among A_{i-1} and A_{i+1} are less than A_i.
Here, assume A_0 = A_{X+Y+Z} and A_{X+Y+Z+1} = A_1.
You are given T test cases. Solve each of them.
Constraints
- 1 \le T \le 2 \times 10^{5}
- 0 \le X,Y,Z \le 10^{9}
- 3 \le X + Y + Z
Input
The input is given from Standard Input in the following format:
T \mathrm{case}_1 \mathrm{case}_2 \vdots \mathrm{case}_T
Each test case is given in the following format:
X\ Y\ Z
Output
Output T lines. The i-th (1 \le i \le T) line should contain Yes
if such a sequence exists, and No
otherwise.
Sample Input 1
4 2 1 1 3 4 5 1359 1998 1022 392848293 683919483 822948689
Sample Output 1
Yes No Yes No
For the first test case, the sequence A = (2,0,0,1) satisfies the condition.
For the second test case, no sequence satisfies the condition.