QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 1024 MB 总分: 100 难度: [显示] 可 Hack ✓

#14019. 偶回路

统计

小蓝鱼有一个由 $n$ 个正整数组成的序列 $a_1, a_2, \dots, a_n$。他想从序列 $a$ 中选择一个长度为偶数的最短非空子序列,使得该子序列的异或和为零。

形式化地,小蓝鱼想要找到一个下标数组 $1 \le i_1 < i_2 < \dots < i_k \le n$,满足:

  • $k > 0$
  • $k \equiv 0 \pmod 2$
  • $a_{i_1} \oplus a_{i_2} \oplus \dots \oplus a_{i_k} = 0$

这里,$\oplus$ 表示按位异或(XOR)运算。例如,$2 \oplus 3 = 1$,$5 \oplus 1 = 4$,$3 \oplus 3 = 0$。

小蓝鱼想让你确定是否可以选出这样的子序列,如果可以,该子序列的最短长度是多少。

输入格式

第一行包含一个整数 $n$($2 \le n \le 2 \times 10^5$)。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$($0 \le a_i < 2^{22}$)。

输出格式

如果无法选择这样的子序列,输出单行 “No”。

否则,输出的第一行应包含单词 “Yes”。然后,输出的第二行应包含一个整数,表示最小可能的 $k$。

样例

输入样例 1

3
1 2 1

输出样例 1

Yes
2

输入样例 2

5
7 4 3 1 2

输出样例 2

Yes
4

输入样例 3

6
40 63 64 9 6 1

输出样例 3

No

说明

在第一个样例中,当 $k = 2$ 且 $i_1 = 1, i_2 = 3$ 时,满足题目的条件。因此,答案为 2。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.