P16346 Impossible Problem

Background

Source of this problem: https://www.luogu.com.cn/contest/314899.

Description

There is a sequence $a$ of length $n$. Each time, you may choose an interval such that the sum of the numbers in this interval is odd, and then add $1$ to every number in this interval. Determine whether it is possible to make all numbers in the sequence equal. If possible, output `Yes`; otherwise, output `No`.

Input Format

This problem has multiple test cases. The first line contains a positive integer $T$. For each testdata: - The first line contains a positive integer $n$. - The second line contains $n$ non-negative integers representing the sequence $a$.

Output Format

For each testdata: - Output one string on a single line representing your answer.

Explanation/Hint

**Constraints** For $100\%$ of the data, $1 \le T \le 10^4$, $1 \le n \le 500$, $1 \le a_i \le 10^{9}$. | Test Point ID | $n \le$ | Score | |:-:|:-:|:-:| | $1$ | $1$ | $10$ | | $2$ | $2$ | $10$ | | $3$ | $3$ | $10$ | | $4$ | $4$ | $10$ | | $5$ | $5$ | $10$ | | $6$ | $6$ | $10$ | | $7$ | $7$ | $10$ | | $8$ | $8$ | $10$ | | $9$ | $9$ | $10$ | | $10$ | $500$ | $10$ | Translated by ChatGPT 5