MAXOR - MAXOR
You are given a sequence A[1], A[2] ... A[N]. (0 ≤ A[i] < 231, 1 ≤ N ≤ 12000).
A query is defined as follows:
- Query(x, y) = Max { a[i] xor a[i+1] xor ... xor a[j] ; l ≤ i ≤ j ≤ r }.
- l = min ( ((x+lastans) mod N)+1, ((y+lastans) mod N)+1 ).
- r = max ( ((x+lastans) mod N)+1, ((y+lastans) mod N)+1 ).
- lastans[1] = 0 , lastans[i] = Query[i-1].
Given M queries, your program must output the results of these queries. (0 ≤ M ≤ 6000).
IMPORTANT : PROBLEM ENHANCED. ( I'M SO SORRY.. )
Input
- The first line of the input file contains 2 numbers : N M.
- In the second line, N numbers follow.
- M lines follow, where line i contains 2 numbers xi and yi.
Output
Your program should output the results of the M queries, one query per line.
Example
Input: 3 3 1 4 3 0 1 0 1 4 3 Output: 5 7 7
hide comments
[Rampage] Blue.Mary:
2016-10-14 17:58:14
The time limit is ridiculous, my first program runs for 0.56 second in the worst test case and get TLE. After added a little constant optimization it gets AC. |
|
Seter:
2012-04-27 04:25:05
@Devil D
|
|
Siarhei Kulik:
2012-04-26 11:48:17
@seter, agree.. |
|
Devil D:
2012-04-26 11:08:04
What is the significance of x & y,
|
|
Seter:
2012-04-26 10:17:28
@sk Easy problems are seldom needed.. |
|
Siarhei Kulik:
2012-04-25 17:12:24
Thanks, enhanced version is more interesting than the previous one. But I think that next time it would be better to make one more problem (well, with another testdata and some changes in the statement) instead of changing the existing one. |
Added by: | Fotile |
Date: | 2012-04-23 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | seter |