#P6783. Sum of Weights of Covered Key Points

    ID: 19990 Type: Default 1000ms 256MiB

Sum of Weights of Covered Key Points

Sum of Weights of Covered Key Points

You are given a two-dimensional plane with n key points, m rectangles, and q queries. Each key point has a weight \(a_i\) and a coordinate \((x,y)\). Each rectangle is defined by its lower-left corner \((x_i, y_i)\) and upper-right corner \((x'_i, y'_i)\). A rectangle covers a point \((a,b)\) if and only if \(x_i \le a \le x'_i\) and \(y_i \le b \le y'_i\).

For each query, you are given an interval \([l, r]\) which refers to the indices of the rectangles. A key point is considered covered by the rectangles in the interval \([l, r]\) if it lies inside at least one of the rectangles whose indices lie in \([l, r]\). Your task is to calculate the sum of the weights of all key points that are covered by the rectangles in the given interval.

Note: The indices for rectangles are 1-indexed.

inputFormat

The first line contains three space-separated integers \(n\), \(m\), and \(q\) representing the number of key points, rectangles, and queries respectively.

The next \(n\) lines each contain three integers \(x\), \(y\), and \(a\) representing the x-coordinate, y-coordinate, and weight of a key point.

The following \(m\) lines each contain four integers \(x_i\), \(y_i\), \(x'_i\), and \(y'_i\) representing the lower-left and upper-right corners of a rectangle.

The next \(q\) lines each contain two integers \(l\) and \(r\) indicating the range of rectangle indices (1-indexed) for that query.

outputFormat

For each query, output a single line containing one integer, which is the sum of the weights of all key points that are covered by at least one rectangle in the interval \([l, r]\).

sample

3 2 2
1 1 5
3 3 10
2 2 7
0 0 2 2
2 2 4 4
1 1
1 2
12

22

</p>