Aman Jr and Crazy Cataloguing

All submissions for this problem are available.
Aman Jr. is a very organized student. He is preparing for IITJEE 2042 and is set to get AIR1 thanks to his unique Book catalogue. Aman’s book catalogue is in the form of a directed tree with N shelves (that is, each node is in the form of a shelf). Each shelf has compartments numbered from 1 to M. [You can visualize the shelf as an array of compartments]. The tree is rooted at Shelf 1.
Despite being an ideal student, Aman too gets distracted. As part of his bouts of craziness, he has decided to have some fun with his catalogue.
Aman defines the “Quality” of a shelf (or node) Si as the Maximum “book quality” of any compartment in the range Li and Ri (the range is called the Effective Range of that shelf).
Aman has the initial configuration of the tree and the shelves in the form of the book quality at each compartment of each shelf. He decides to perform 3 types of operations:
Updates
Type 1: Increase the book quality of compartments in Shelf Y in the range L to R (inclusive) by X.
Type 2: Change the Effective Range of Shelf Y and make it L to R (inclusive)
Queries:
Type 3: Find the sum of “qualities” of the shelves in the subtree of Shelf Y at that instant..
Can you help perform these operations on his catalogue? He will reward you by giving you “gud Irodov kweschuns.”
Please note that all characters in this problem are fictional, and they will never exist.
Input
The first line contains 3 integers, N, M, Q, where N and M are as described above and Q is the number of operations.
The next N1 Lines contain 2 integers, x and y, the description of the edges of the tree.
The next N lines contain M integers. The Y^{th} line has M integers describing the initial “book quality” of the coordinates from 1 to M in the Y^{th} shelf.
The next N lines contain 2 integers, Li and Ri, the initial effective range of the ith node.
The next Q lines contain the description of the queries:
The first integer specifies the type of the operation.
If the first integer is 1, 4 space separated integers follow, Y, L, R, X as described above [Type 1]
If the first integer is 2, 3 space separated integers follow, Y, L, R as described above [Type 2]
If the first integer is 3, 1 space separated integer follows, Y as described above [Type 3]
Output
For each query of type 3, output a single integer on a new line, the sum of “qualities” of the shelves in the subtree of Shelf X at that instant.
Constraints
1 <= N <= 1000
1 <= M <= 1000
1 ,<= Q <= 200000
0 <= Initial Book quality at a coordinate <= 1e5
0 <= X <= 1e5
Subtask 1: (10 points)
1 <= N <= 100
1 <= M <= 100
1 <= Q <= 1000
Subtask 2: (15 points)
1 <= N <= 1000
1 <= M <= 100
1 <= Q <= 10000
Subtask 3: (15 points)
1 <= N <= 100
1 <= M <= 1000
1 <= Q <= 10000
Subtask 4: (60 points)
Original Constraints
Input: 6 4 10 1 2 1 4 1 3 4 5 4 6 2 3 1 4 5 2 3 6 5 5 5 5 1 2 3 4 1 1 2 1 7 0 2 3 2 4 1 3 1 1 2 2 1 2 1 4 3 1 3 3 3 4 1 5 1 4 5 2 4 1 4 3 1 3 4 1 4 1 2 5 3 4 3 1 Output: 24 5 10 31 17 20 34
Author:  harrycoda 
Tags  harrycoda 
Date Added:  17112017 
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, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions