Yet Another Tetris Problem

题意翻译

### 题目描述 你有一个数列 $\{a_n\}$,现在有两种操作: 1. 当数列 $\{a_n\}$ 的任意一项大于 $0$ 时,你可以选择**一些** $i(1\le i\le n)$,把每个 $a_i$ 加上 $2$。 2. 当数列 $\{a_n\}$ 的每一项都大于 $0$ 时,把这个数列的每一项都减去 $1$。 问你最后能不能把 $\{a\}$ 数组的元素全部变成 $0$。如果能,输出 `YES`,不然输出 `NO`。 ### 输入格式 **本题有多组数据。** 第一行一个整数 $t$,表示数据组数。 每组数据包含两行,第一行一个整数 $n$,表示数列的长度;第二行有 $n$ 个整数,表示数列 $\{a_n\}$。 ### 输出格式 对于每组数据,输出 `YES` 或 `NO`,每行一个。 ### 数据范围 $1\le t\le 100$,$1\le n\le 100$,$1\le a_i\le 100$。

题目描述

You are given some Tetris field consisting of $ n $ columns. The initial height of the $ i $ -th column of the field is $ a_i $ blocks. On top of these columns you can place only figures of size $ 2 \times 1 $ (i.e. the height of this figure is $ 2 $ blocks and the width of this figure is $ 1 $ block). Note that you cannot rotate these figures. Your task is to say if you can clear the whole field by placing such figures. More formally, the problem can be described like this: The following process occurs while at least one $ a_i $ is greater than $ 0 $ : 1. You place one figure $ 2 \times 1 $ (choose some $ i $ from $ 1 $ to $ n $ and replace $ a_i $ with $ a_i + 2 $ ); 2. then, while all $ a_i $ are greater than zero, replace each $ a_i $ with $ a_i - 1 $ . And your task is to determine if it is possible to clear the whole field (i.e. finish the described process), choosing the places for new figures properly. You have to answer $ t $ independent test cases.

输入输出格式

输入格式


The first line of the input contains one integer $ t $ ( $ 1 \le t \le 100 $ ) — the number of test cases. The next $ 2t $ lines describe test cases. The first line of the test case contains one integer $ n $ ( $ 1 \le n \le 100 $ ) — the number of columns in the Tetris field. The second line of the test case contains $ n $ integers $ a_1, a_2, \dots, a_n $ ( $ 1 \le a_i \le 100 $ ), where $ a_i $ is the initial height of the $ i $ -th column of the Tetris field.

输出格式


For each test case, print the answer — "YES" (without quotes) if you can clear the whole Tetris field and "NO" otherwise.

输入输出样例

输入样例 #1

4
3
1 1 3
4
1 1 2 1
2
11 11
1
100

输出样例 #1

YES
NO
YES
YES

说明

The first test case of the example field is shown below: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1324A/2ecdd2a3b945fba43a635ca66c5bad0349190c6d.png) Gray lines are bounds of the Tetris field. Note that the field has no upper bound. One of the correct answers is to first place the figure in the first column. Then after the second step of the process, the field becomes $ [2, 0, 2] $ . Then place the figure in the second column and after the second step of the process, the field becomes $ [0, 0, 0] $ . And the second test case of the example field is shown below: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1324A/c37b4ffc9a98440045cf9a89fb956f7445051e41.png) It can be shown that you cannot do anything to end the process. In the third test case of the example, you first place the figure in the second column after the second step of the process, the field becomes $ [0, 2] $ . Then place the figure in the first column and after the second step of the process, the field becomes $ [0, 0] $ . In the fourth test case of the example, place the figure in the first column, then the field becomes $ [102] $ after the first step of the process, and then the field becomes $ [0] $ after the second step of the process.