I got Wrong Answer on test #26 in the final system test on this problem : Greg and Array
I used binary indexed trees to solve the problem. Since the full test case is not visible, I am unable to find my mistake. Here is the code I submitted: Source Code
I first calculated the number of operations of each kind on the array (op[] in the code) and then used this to find the total value change in the final array (query[] in the code). I printed the result after adding the total value changes to the original array values.
Any help on what am I doing wrong or other optimizations would be highly appreciated. I am a beginner and this is the first time I used binary indexed tree in my submission during a contest.
Expression d[t]*op[t] may overflow!
Oh right! Silly mistake :( I just submitted again in practice and got Accepted (Code). Thanks for the help :)