Array Simulation

Limits: 2s, 512 MB

You are given an array of N elements. Initially all the indices have a value of 0. You have to do four types of works on this array:


This is a companion discussion topic for the original entry at https://toph.co/p/array-simulation