I am new to this website, but I will try to make my question acceptable.
I am working on a problem, here is the statement:
"In a square matrix with maximal dimensions m * m, you should answer the queries. There are 2 types of queries :
1) 1 x y v you should open a store on coordinates x,y with value v (it is possible two have more than 1 stores on the same x, y)
2) 2 x y you need to output the time needed to move all of the value to the xy place (not to move, just to calculate the time for that), and the time is being calculated like this: v*(abs(a - x) + abs(c - y)) for some spot x, y, v.
Input: n (n <= 250.000), m (m <= 10^9). In the next n lines tou are given either 1 x y v, or 2 x y (x, y <= m and v <= 10^4).
Any ideas? Is this some tree, or something like that, should I read first some tutorial for an algorithm or data structure, please help me.
Aucun commentaire:
Enregistrer un commentaire