No.2672 Subset Xor Sum
問題文最終更新日: 2024-03-15 21:21:48
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 421 (NUPC2023)
(順位表)
の他の問題:
Problem Statement
You are given a sequence of non-negative integers $A = (A_1 , A_2 , \dots , A_N)$ of length $N$.
You want to split the sequence $A$ into $2$ subsequences $B = (B_1, B_2, \dots, B_M)$ and $C = (C_1, C_2, \dots, C_{N-M})$ satisfying the following conditions.
- $1 \leq M \leq N-1$
- $B_1 \oplus B_2 \oplus \dots \oplus B_M = 0$
- $C_1 \oplus C_2 \oplus \dots \oplus C_{N-M} = 0$
Here, $\oplus$ denotes the bitwise exclusive OR (Bitwise XOR).
If the above split is possible, print Yes; otherwise, print No.
What it means to split the sequence $A$ into $2$ subsequences $B$ and $C$
It refers to the following operation.
- Let $B, C$ be empty sequences.
- For each $i = 1, 2, \dots, N$, in this order, append $A_i$ to the end of $B$ or the end of $C$.
Input
The input is given from Standard Input in the following format.
$N$ $A_1$ $A_2$ $\dots$ $A_N$
Output
If the above split is possible, print Yes; otherwise, print No. Then print a newline.
Constraints
- All input values are integers.
- $2 \leq N \leq 5 \times 10^5$
- $0 \leq A_i \leq 5000$
Sample
Sample 1
Input
6 1 12 4 3 2 8
Output
Yes
For example, splitting into $B = (12 , 4 , 8), C = (1, 3, 2)$ satisfies the above conditions.
Sample 2
Input
4 1 3 8 10
Output
No
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Xelmeph
null
ngtkana
eoeo