#FT0000131. Mishka và phép XOR thú vị (Mishka and Interesting Sum)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Mishka và phép XOR thú vị (Mishka and Interesting Sum)
Mishka and Interesting Sum
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a sequence of positive integers, answer closed interval queries .
For each interval, take each distinct value that occurs a positive even number of times, exactly once, and XOR all such values. Values with odd frequency are excluded. Print zero if no value qualifies.
For example, in 1 2 1 2 2 3 3, values 1 and 3 occur twice, while 2 occurs three times, so the answer is . This is not the XOR of all elements.
Input
- First line: .
- Second line: values .
- Third line: .
- Next lines: one query each.
Output
Print one nonnegative XOR result per query, in input order.
Subtasks
- Subtask 1 (20 points): ; ; ; , where is the maximum in this subtask.
- Subtask 2 (30 points): ; ; ; , where is the maximum in this subtask.
- Subtask 3 (50 points): ; ; ; , where is the maximum in this subtask.
Examples
Example 1
Input
3
3 7 8
1
1 3
Output
0
Explanation
All values of 3 7 8 in occur once, so no value has a positive even frequency. The result is 0.
Example 2
Input
7
1 2 1 3 3 2 3
5
4 7
4 5
1 3
1 7
1 5
Output
0
3
1
3
2
Explanation
For [4,7] = 3 3 2 3, both values occur an odd number of times, yielding 0. [4,5] = 3 3 yields 3. [1,3] = 1 2 1 yields 1. In the full range, values 1 and 2 each occur twice, yielding . Range [1,5] yields .