标签:names time more data- element dep out math you
You are given some Tetris field consisting of nn columns. The initial height of the ii-th column of the field is aiai blocks. On top of these columns you can place only figures of size 2×12×1 (i.e. the height of this figure is 22 blocks and the width of this figure is 11 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 aiai is greater than 00:
- You place one figure 2×12×1 (choose some ii from 11 to nn and replace aiai with ai+2ai+2);
- then, while all aiai are greater than zero, replace each aiai with ai−1ai−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 tt independent test cases.
Input
The first line of the input contains one integer tt (1≤t≤1001≤t≤100) — the number of test cases.
The next 2t2t lines describe test cases. The first line of the test case contains one integer nn (1≤n≤1001≤n≤100) — the number of columns in the Tetris field. The second line of the test case contains nnintegers a1,a2,…,ana1,a2,…,an (1≤ai≤1001≤ai≤100), where aiai is the initial height of the ii-th column of the Tetris field.
Output
For each test case, print the answer — "YES" (without quotes) if you can clear the whole Tetris field and "NO" otherwise.
Example
Input4 3 1 1 3 4 1 1 2 1 2 11 11 1 100OutputYES NO YES YES
水题,全奇数或全偶数就是yes,反之是no
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); int m = n; int x = 0; while (m--) { int p; scanf("%d", &p); x += (p % 2); } if (x == n || x == 0) { printf("YES\n"); } else { printf("NO\n"); } } return 0; }
A - Yet Another Tetris Problem
标签:names time more data- element dep out math you
原文地址:https://www.cnblogs.com/Vetsama/p/12494983.html