#P2163. [SHOI2007] 园丁的烦恼
[SHOI2007] 园丁的烦恼
Description
It seems ordinary hard problems cannot stump this gardener. The king decided to exhaust his strength with a war of attrition: "Young man, there are trees in my garden, and each tree can be represented by an integer coordinate. Soon, my knights will come in turns to ask you how many trees lie inside a certain rectangle. If you cannot answer immediately and correctly, be ready to leave!" After saying this, the king stormed off.
Now it was the gardener's turn to be dumbfounded—he had not prepared for such a problem. Fortunately, as the president of the "National Gardeners Protection Alliance"—you—can become his last lifeline.
Input Format
The first line contains two integers , representing the number of trees and the number of queries.
The next lines each contain two integers , indicating that there is a tree at coordinate . It is possible that two trees share the same coordinate.
The next lines each contain four integers , describing a query: count how many trees are inside the rectangle with lower-left corner and upper-right corner , including the boundary.
Output Format
For each query, output a single integer on its own line indicating the answer.
3 1
0 0
0 1
1 0
0 0 1 1
3
Hint
Constraints and Conventions
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号