#P5795. [THUSC 2015] 异或运算
[THUSC 2015] 异或运算
Description
Given a sequence of length and a sequence of length , define a matrix where the value in row and column is .
For each query, you are given a rectangular region . Find the -th largest value among all in this region.
Input Format
The first line contains two positive integers , representing the lengths of the two sequences.
The second line contains non-negative integers .
The third line contains non-negative integers .
The fourth line contains a positive integer , representing the number of queries.
The next lines each contain five positive integers , describing one query. The meanings are as stated above.
Output Format
Output lines. Each line contains one non-negative integer, the answer to the corresponding query.
3 3
1 2 4
7 6 5
3
1 2 1 2 2
1 2 1 3 4
2 3 2 3 4
6
5
1
Hint
For of the data:
- .
- .
- .
- , .
Translated by ChatGPT 5
京公网安备 11011102002149号