PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000144. Các đoạn có XOR bằng nhau (Equal XOR Segments)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Các đoạn có XOR bằng nhau (Equal XOR Segments)
Equal XOR Segments
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an array of nonnegative integers. A consecutive subarray is called valid if it can be partitioned into at least two nonempty consecutive parts such that the bitwise XOR of each part has the same value. Every element must belong to exactly one part, and the original order is preserved.
For each of queries , determine whether the subarray is valid. We denote bitwise XOR by .
Input
- The first line contains , the array length and the number of queries.
- The second line contains integers .
- Each of the next lines contains two indices . Indices are -based.
Output
Print YES or NO on a separate line for each query, in order.
Subtasks
- Subtask 1 (20 points): ; ; ; for every query.
- Subtask 2 (30 points): ; ; ; for every query.
- Subtask 3 (50 points): ; ; ; for every query.
Examples
Input
5 3
1 1 2 3 0
1 5
2 3
1 2
Output
YES
NO
YES
Explanation
- For , the partition , , has XOR values , , and , so the answer is
YES. - For , the elements can only be split into and , whose XOR values differ; hence
NO. - For , and have equal XOR values, so the answer is
YES.