309370: CF1669C. Odd/Even Increments

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:2 Solved:0

Description

Odd/Even Increments

题意翻译

### 题目描述 给定一个长为 $n$ 数组 $a=[a_1,a_2,a_3····,a_n]$ ,您可以对其进行两种类型的操作: 1.将 $1$ 添加到具有奇数索引的每个元素。换句话说,改变数组如下:$a_1=a_1+1,a_3=a_3+1,a_5=a_5+1,......$ 2.将 $1$ 添加到具有偶数索引的每个元素。换句话说,改变数组如下:$a_2=a_2+1,a_4=a_4+1,a_6=a_ 6+1,......$ 确定经过任意次数的操作后,是否有可能使最终数组仅包含偶数或仅包含奇数。换句话说,确定是否可以使数组的所有元素在经过任意次数的操作后具有相同的奇偶性。 请注意,您可以多次执行这两种类型的操作(甚至没有)。不同类型的操作可以执行不同的次数。 ### 输入格式 第一行包含一个整数 $t\ (1\le t \le 100)$ — 测试样例的数量。 每个测试样例的第一行包含一个整数 $ n\ (2 \le n \le 50)$ 。 每个测试用例的第二行包含 $n$ 个整数 $a_1,a_2,a_3,....,a_n\ (1\le a_i\le 10^3)$ —数组的元素。 请注意,在执行操作之后,数组中的元素可能会变得大于 $10^3$。 ### 输出格式 输出 $t$ 列,每列都包含对应测试用例的答案。如果经过任意次数的操作后可以使最终数组仅包含偶数或奇数,则输出“YES”,否则输出“NO”。 您可以输出任何合法的答案(例如,字符串“yEs”、“yes”、“Yes”和“YES”将被识别为正确答案)。 ### 输入输出样例 #### 输入 #1 ``` 4 3 1 2 1 4 2 2 2 3 4 2 2 2 2 5 1000 1 1000 1 1000 ``` #### 输出 #1 ``` YES NO YES YES ``` ### 说明/提示 对于第一个测试用例,可以增加偶数索引的元素,得到数组 $[1, 3, 1]$ ,它只包含奇数,所以答案是“YES”。 对于第二个测试用例,可以证明在执行任意数量的操作后,我们将无法使所有元素具有相同的奇偶性,因此答案是“NO”。 对于第三个测试用例,元素已经具有相同的奇偶性,因此答案是“YES”。 对于第四个测试用例,可以执行一次操作,将奇数位置的所有元素都增加 11 ,从而得到数组 $[1001, 1, 1001, 1, 1001]$ ,所有元素变成奇数,所以答案是“YES”。

题目描述

Given an array $ a=[a_1,a_2,\dots,a_n] $ of $ n $ positive integers, you can do operations of two types on it: 1. Add $ 1 $ to every element with an odd index. In other words change the array as follows: $ a_1 := a_1 +1, a_3 := a_3 + 1, a_5 := a_5+1, \dots $ . 2. Add $ 1 $ to every element with an even index. In other words change the array as follows: $ a_2 := a_2 +1, a_4 := a_4 + 1, a_6 := a_6+1, \dots $ . Determine if after any number of operations it is possible to make the final array contain only even numbers or only odd numbers. In other words, determine if you can make all elements of the array have the same parity after any number of operations. Note that you can do operations of both types any number of times (even none). Operations of different types can be performed a different number of times.

输入输出格式

输入格式


The first line contains an integer $ t $ ( $ 1 \leq t \leq 100 $ ) — the number of test cases. The first line of each test case contains an integer $ n $ ( $ 2 \leq n \leq 50 $ ) — the length of the array. The second line of each test case contains $ n $ integers $ a_1, a_2, \dots, a_n $ ( $ 1 \leq a_i \leq 10^3 $ ) — the elements of the array. Note that after the performed operations the elements in the array can become greater than $ 10^3 $ .

输出格式


Output $ t $ lines, each of which contains the answer to the corresponding test case. As an answer, output "YES" if after any number of operations it is possible to make the final array contain only even numbers or only odd numbers, and "NO" otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

输入输出样例

输入样例 #1

4
3
1 2 1
4
2 2 2 3
4
2 2 2 2
5
1000 1 1000 1 1000

输出样例 #1

YES
NO
YES
YES

说明

For the first test case, we can increment the elements with an even index, obtaining the array $ [1, 3, 1] $ , which contains only odd numbers, so the answer is "YES". For the second test case, we can show that after performing any number of operations we won't be able to make all elements have the same parity, so the answer is "NO". For the third test case, all elements already have the same parity so the answer is "YES". For the fourth test case, we can perform one operation and increase all elements at odd positions by $ 1 $ , thus obtaining the array $ [1001, 1, 1001, 1, 1001] $ , and all elements become odd so the answer is "YES".

Input

题意翻译

### 题目描述 给定一个长为 $n$ 数组 $a=[a_1,a_2,a_3····,a_n]$ ,您可以对其进行两种类型的操作: 1.将 $1$ 添加到具有奇数索引的每个元素。换句话说,改变数组如下:$a_1=a_1+1,a_3=a_3+1,a_5=a_5+1,......$ 2.将 $1$ 添加到具有偶数索引的每个元素。换句话说,改变数组如下:$a_2=a_2+1,a_4=a_4+1,a_6=a_ 6+1,......$ 确定经过任意次数的操作后,是否有可能使最终数组仅包含偶数或仅包含奇数。换句话说,确定是否可以使数组的所有元素在经过任意次数的操作后具有相同的奇偶性。 请注意,您可以多次执行这两种类型的操作(甚至没有)。不同类型的操作可以执行不同的次数。 ### 输入格式 第一行包含一个整数 $t\ (1\le t \le 100)$ — 测试样例的数量。 每个测试样例的第一行包含一个整数 $ n\ (2 \le n \le 50)$ 。 每个测试用例的第二行包含 $n$ 个整数 $a_1,a_2,a_3,....,a_n\ (1\le a_i\le 10^3)$ —数组的元素。 请注意,在执行操作之后,数组中的元素可能会变得大于 $10^3$。 ### 输出格式 输出 $t$ 列,每列都包含对应测试用例的答案。如果经过任意次数的操作后可以使最终数组仅包含偶数或奇数,则输出“YES”,否则输出“NO”。 您可以输出任何合法的答案(例如,字符串“yEs”、“yes”、“Yes”和“YES”将被识别为正确答案)。 ### 输入输出样例 #### 输入 #1 ``` 4 3 1 2 1 4 2 2 2 3 4 2 2 2 2 5 1000 1 1000 1 1000 ``` #### 输出 #1 ``` YES NO YES YES ``` ### 说明/提示 对于第一个测试用例,可以增加偶数索引的元素,得到数组 $[1, 3, 1]$ ,它只包含奇数,所以答案是“YES”。 对于第二个测试用例,可以证明在执行任意数量的操作后,我们将无法使所有元素具有相同的奇偶性,因此答案是“NO”。 对于第三个测试用例,元素已经具有相同的奇偶性,因此答案是“YES”。 对于第四个测试用例,可以执行一次操作,将奇数位置的所有元素都增加 11 ,从而得到数组 $[1001, 1, 1001, 1, 1001]$ ,所有元素变成奇数,所以答案是“YES”。

加入题单

算法标签: