Darshan And His Spreadsheet

All submissions for this problem are available.
Agarwal Inc. is the biggest company in the tech industry. Working there is both prestigious and exhausting. Because of the hardworking and very disciplined nature of the CEO Yash Agarwal, he expects his employees to be the same. Darshan, an employee in his organization, is too lazy! People couldn't believe Darshan got placed there. On his first day, Darshan was given some documentation work. Working on a spreadsheet can be very stressful sometimes. Darshan is working on a spreadsheet right now given by his CEO. The dimensions of the spreadsheet are $N$ rows and $M$ columns. Each cell represented by a row number $R_i$ and column number $C_i$ either contains a word of size $S_i$ or would be empty. Size of a word equals to the number of characters in that word. Now, Yash wants him to answer his $Q$ queries. Considering all cells whose row number and column number lie in the range [$(X_1)_i$,$(Y_1)_i$] and [$(X_2)_i$,$(Y_2)_i$], the boss demands the total number of characters in these cells. Now Darshan does not know how to do this! He asks for your help. ###Input:  First line will contain $T$, number of testcases. Then the testcases follow.  First line contains number of rows and columns $N$ and $M$  Next line contains number of non empty cells $K$  Next $K$ line conatins row number $R_i$, column number $C_i$, size of word $S_i$  Next line contains number of queries $Q$  Next $Q$ lines contains four space separated integers $(X_1)_i$,$(Y_1)_i$,$(X_2)_i$,$(Y_2)_i$. ###Output: For each testcase, for each query, print the total number of characters of the cells whose row number and column number lie inside the given range. ###Constraints  $1 \leq T \leq 5$  $1 \leq N,M \leq 10^9$  $1 \leq K \leq 10^5$  $1 \leq R_i \leq N$  $1 \leq C_i \leq M$  $1 \leq S_i \leq 10^9$  $1 \leq Q \leq 10^5$  $1 \leq (X_1)_i \leq (X_2)_i \leq N$  $1 \leq (Y_1)_i \leq (Y_2)_i \leq M$ ###Sample Input: 1 4 4 4 1 1 1 1 2 2 2 1 3 2 2 4 2 1 1 2 2 3 3 4 4 ###Sample Output: 10 0Author:  buzz_95 
Tags  buzz_95 
Date Added:  14082019 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions