#P6783. [Ynoi2008] rrusq
[Ynoi2008] rrusq
Problem Description
Given a 2D plane, there are key points, rectangles, and queries. Each key point has a weight .
A rectangle with bottom-left corner and top-right corner contains a point if and only if and .
In each query, you are given . For a key point , if point lies in any rectangle whose index is within , then we say that point is jointly contained by the rectangles in interval . Output the sum of weights of all key points jointly contained by the rectangles in interval .
Input Format
The first line contains an integer .
Then follow lines, each containing two elements , meaning the -th key point is with weight . It is guaranteed that is a permutation of to .
Then one line contains an integer .
Then follow lines, each containing four elements , meaning the bottom-left corner of the -th rectangle is and the top-right corner is .
Then one line contains an integer .
Then follow lines, each containing two elements , meaning a query on interval .
Output Format
For each query, output one line with one integer representing the answer.
10
6 4
2 3
4 3
10 8
8 8
9 9
7 3
1 9
5 7
3 7
10
1 3 2 5
3 7 8 10
3 4 3 6
3 4 5 7
6 8 1 8
4 9 6 9
1 5 6 9
4 9 2 7
1 1 1 5
1 1 4 9
10
2 6
7 8
2 8
6 9
9 10
4 5
5 6
3 7
7 10
1 2
40
22
51
31
4
12
29
36
22
31
Hint
Idea: nzhtl1477&ccz181078, Solution: zx2003, Code: ccz181078, Data: nzhtl1477.
Note: This problem uses bundled testdata. You can only get the score for a subtask after you pass all test points in that subtask.
For of the testdata, it is Sample 1.
For another of the testdata, .
For another of the testdata, .
For another of the testdata, .
For another of the testdata, .
For of the testdata, , .
, , , 。
Translated by ChatGPT 5