No.3666 League of Jigsaw
タグ : / 解いたユーザー数 10
作問者 :
sepa38
Problem Statement
There is a rectangular grid with $3$ rows and $N$ columns. Chawanmushi-kun wants to tile this grid without gaps using three types of tetromino blocks, the "L", "J", and "O" shapes shown in the figure below. From left to right, they are the L, J, and O tetrominoes.
Chawanmushi-kun has $l$ L-blocks, $j$ J-blocks, and $o$ O-blocks. The blocks may be freely rotated and translated, but they may not be flipped (for example, an L-block cannot be used as a J-block).
Determine whether the grid can be completely tiled using all the blocks he has, with no block extending outside the grid and no blocks overlapping. It is guaranteed that the total number of cells in the grid equals the total number of cells in the blocks, that is, $3N=4(l+j+o)$ always holds.
You are given $T$ test cases; solve each of them.
Constraints
- $1 \leq T \leq 2 \times 10^{5}$
- $0 \le l,j,o \le 10^9$
- $4(l+j+o)$ is a multiple of $3$
- All input values are integers
Input
The input is given from standard input in the following format.
$T$
$\text{case}_1$
$\text{case}_2$
$\vdots$
$\text{case}_T$
Each test case is given in the following format.
$l\ j\ o$
Output
Print Yes if the grid can be tiled, and No otherwise. Print a newline at the end.
Sample
Sample 1
Input
9 1 1 1 4 2 0 1 3 2 2 1 0 0 5 1 1 7 1 10 2 0 2718 2818 284 3141592 6535897 93238462
Output
Yes Yes Yes No No Yes Yes Yes No
For the first test case, the $3\times 4$ grid can be tiled as shown in the figure below.
For the second test case, the $3\times 8$ grid can be tiled as shown in the figure below.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。