D - AtCoder Express 2
Time Limit: 3 sec / Memory Limit: 1000 MB
Score: 400400 points
In Takahashi Kingdom, there is a east-west railroad and NN cities along it, numbered 11, 22, 33, ..., NN from west to east. A company called AtCoder Expresspossesses MM trains, and the train ii runs from City LiLi to City RiRi (it is possible that Li=RiLi=Ri). Takahashi the king is interested in the following QQ matters:
Although he is genius, this is too much data to process by himself. Find the answer for each of these QQ queries to help him.
Input is given from Standard Input in the following format:
NN MM QQ L1L1 R1R1 L2L2 R2R2 :: LMLM RMRM p1p1 q1q1 p2p2 q2q2 :: pQpQ qQqQ
Print QQ lines. The ii-th line should contain the number of the trains that runs strictly within the section from City pipi to City qiqi.
Copy
2 3 1 1 1 1 2 2 2 1 2
Copy
3
As all the trains runs within the section from City 11 to City 22, the answer to the only query is 33.
Copy
10 3 2 1 5 2 8 7 10 1 7 3 10
Copy
1 1
The first query is on the section from City 11 to 77. There is only one train that runs strictly within that section: Train 11. The second query is on the section from City 33 to 1010. There is only one train that runs strictly within that section: Train 33.
Copy
10 10 10 1 6 2 9 4 5 4 7 4 7 5 8 6 6 6 7 7 9 10 10 1 8 1 9 1 10 2 8 2 9 2 10 3 8 3 9 3 10 1 10
Copy
7 9 10 6 8 9 6 7 8 10
题目大意:给出一个区间1-n有m辆火车,每辆火车有自己的行驶区间,每次询问有一个l,r问l,r内有多少辆火车。
解题思路:把火车看做成二维平面上的点,每次求一下区间[l,l]-[r,r]内点的个数。
#include
#include
#include
#include