#P1527. [国家集训队] 矩阵乘法
[国家集训队] 矩阵乘法
Description
Given an matrix, you do not need to perform matrix multiplication. Instead, for each query, find the -th smallest number in a subrectangle.
Input Format
The first line contains two integers, representing the matrix size and the number of queries .
Lines through each contain integers, representing the matrix. The -th number on line is the number in row and column of the matrix, denoted .
Then lines follow, each containing five integers , representing one query. For each query, find the -th smallest number in the subrectangle with top-left corner and bottom-right corner .
Output Format
For each query, output a single integer on its own line representing the answer.
2 2
2 1
3 4
1 2 1 2 1
1 1 2 2 3
1
3
Hint
Constraints and Conventions
- For of the testdata, it is guaranteed that , .
- For of the testdata, it is guaranteed that , .
- For of the testdata, it is guaranteed that , .
- For of the testdata, it is guaranteed that , , .
Translated by ChatGPT 5
京公网安备 11011102002149号