|
||||||||||
K-short ProblemTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 702 Accepted Submission(s): 224 Problem Description In the view of a satellite, you can see lots of tall buildings in the city, and we assume that the city's border is flat. Now you have observed n tall buildings in the city and recorded their position and height. Due to some mysterious reasons, you need to answer a series of queries. Each query will give you a position(x, y) and k, then you have to find out the k-th shortest building in set{$(x, y) | x \leq X, y \leq Y$}. Input Multiple test cases.For each test case, the first line will contain two integers n and m($0 < n \leq 30000, 0 \leq m \leq 30000$), which represents the amount of buildings and amount of queries. Then n lines follow, contains three integers $x, y, h (-1E9 \leq x, y \leq 1E9, 0 \leq h \leq 1E9)$ indicate the building's position and height in each line. Then there are m lines, each with three integers $x, y, k (-1E9 \leq x, y \leq 1E9, 1 \leq k \leq 10)$ used for query. Output For each test case, if the k-th shortest building exists, output its height in 1 line, otherwise print "-1" (without quotes). Sample Input
Sample Output
Source | ||||||||||
|