Updated problem name
Moving people
Updated problem statement
The people of your city are living in a N x M grid. If a person is out of the grid after multiple instructions, then that person is not counted in further steps.
Initially, there is at most one person in every cell of this grid. You can perform Q operations or query of the following types:
Input format
Output format
For each 2nd type of query, print the number of persons that are available in the grid at the time of that query.
Constraints
1≤N,M≤103
1≤Q≤105
−1000≤X,Y≤1000
After 1stupdate operation, the grid will look like this:
0000
0000
1111
0001
After the 2nd update operation, the grid will look like this:
0000
0000
1110
0010
After the 3rd update operation, the grid will look like this:
0000
0011
0000
0000