#P17124. [ICPC 2025 Shanghai R] Not a subset sum
[ICPC 2025 Shanghai R] Not a subset sum
题目描述
We are given an array of length . For a string of length over the alphabet (-indexed), define the "generalized subset sum" as the sum of over all indices that satisfy:
- For each , if then the -th bit of is .
- For each , if then the -th bit of is .
- If there is no restriction on the -th bit of .
For example, when and , the generalized subset sum is (binary and ). Note that the first bit is the lowest bit.
Your task is to compute the generalized subset sum for each string of length over the alphabet . Because the total output can be large, you only need to output the bitwise XOR of all these sums.
输入格式
The first line of the input contains an integer ().
The second line of the input contains integers (), contents in array .
输出格式
Print an integer denoting the bitwise-XOR of all generalized subset sums.
1
3 5
14
2
2 6 8 8
0
提示
The following are query strings and their corresponding generalized subset sums in sample :
Now it is easy to verify that the output is .