Rivalry

AtCoder
IDarc198_b
Time2000ms
Memory256MB
Difficulty
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$ [samples]
Samples
Input #1
4
2 1 1
3 4 5
1359 1998 1022
392848293 683919483 822948689
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.
API Response (JSON)
{
  "problem": {
    "name": "Rivalry",
    "description": {
      "content": "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",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc198_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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:\n\n*   For every...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments