AHi,
I tried to find out how to solve this task...
I found out that this task needs interval trees.
Now i tried to figure out how to make that tree, but until now it was without success :S...
Can someone give me some hints for solving it ???
fCan you please explain the task in ENGLISH? I don't understand Serbian....
pSimplified, you have an array with maximum size 500000 (starting from 1). Little Z adds, removes and counts boxes in that array. There is 4 types of commands:
"A p q" - means that you should add 1 box to each of the fields in the array from p to q (including p and q). A 2 4 means that you should add one box to 2, one box to 3 and one box to 4.
"R i" - means that you should remove all the boxes you have added in the i-th addition (in the i-th command A). So for example, if you have R 3, then you remove the boxes added in the 3rd addition. Also, 'i' will not appear more than once, so if you have removed 3rd addition, you won't get the same command later again.
"Q p q" - write how many array fields with 1 or more boxes are there in the interval [p,q].
"K" - end of test