#SRD0000147. Dãy con của dãy con (Sub-subsequence)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Dãy con của dãy con (Sub-subsequence)
Sub-subsequence
Source: MarisaOJ
Version: Phuoc Hung OJ Extended
Problem Statement
You are given a nonnegative integer array of length and online queries. Each query supplies two integers . Let lastans denote the preceding query's answer, initially . Decode the interval as
Swap if . Find the maximum bitwise XOR of any nonempty contiguous subarray contained entirely in . Output that maximum, then update lastans before reading the next query.
The queries must be processed in input order; their effective intervals depend on previous answers.
Input
- The first line contains .
- The second line has nonnegative integers .
- Each of the next lines contains the two integers that encode a query.
Output
Print lines. Line contains the maximum XOR of a nonempty contiguous subarray in the decoded interval of query .
Subtasks
- Subtask 1 (20 points): ; ; ; interval indices decoded using
lastans. - Subtask 2 (30 points): ; ; ; interval indices decoded using
lastans. - Subtask 3 (50 points): ; ; ; interval indices decoded using
lastans.
Examples
Example 1
Input
5 3
8 6 2 4 5
0 4
0 2
2 4
Output
14
6
14
Explanation
Initially lastans=0; query decodes to and the subarray has maximum XOR . The next decodes using to , hence ; the single-element subarray yields maximum . The final decodes using to , hence , whose maximum is .