Best Division
Time limit1sMemory limit256 MB
Given a pseudorandom array, find the largest K such that A can be split into K nonempty intervals of length at most L, each with XOR sum at most X.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Prefix sum, Binary search, Greedy
- Solved
- No attempts yet
Problem
You are given an array of integers.
You are also given two integers and .
You must divide the whole array into exactly nonempty intervals so that the length of each interval is at most .
The cost of an interval is the bitwise XOR sum of all elements of whose indices lie in .
The score of a division is the maximum of the costs of all intervals in that division. You care about the best division, the one that minimizes the score. That would be too simple, so the problem is reversed.
Suppose you know the minimum score: the answer to the original problem is at most . Now find the maximum value of .
Input
The first line contains three integers , , and as described above (, ).
The next line contains three integers , , and (). The remaining elements of the array are generated from these three integers as follows: for every , .
Output
Print the answer on a single line. If the answer does not exist, print .