CF436B Om Nom and Spiders
Description
Om Nom really likes candies and doesn't like spiders as they frequently steal candies. One day Om Nom fancied a walk in a park. Unfortunately, the park has some spiders and Om Nom doesn't want to see them at all.
The park can be represented as a rectangular $ n×m $ field. The park has $ k $ spiders, each spider at time 0 is at some cell of the field. The spiders move all the time, and each spider always moves in one of the four directions (left, right, down, up). In a unit of time, a spider crawls from his cell to the side-adjacent cell in the corresponding direction. If there is no cell in the given direction, then the spider leaves the park. The spiders do not interfere with each other as they move. Specifically, one cell can have multiple spiders at the same time.
Om Nom isn't yet sure where to start his walk from but he definitely wants:
- to start walking at time 0 at an upper row cell of the field (it is guaranteed that the cells in this row do not contain any spiders);
- to walk by moving down the field towards the lowest row (the walk ends when Om Nom leaves the boundaries of the park).
We know that Om Nom moves by jumping. One jump takes one time unit and transports the little monster from his cell to either a side-adjacent cell on the lower row or outside the park boundaries.
Each time Om Nom lands in a cell he sees all the spiders that have come to that cell at this moment of time. Om Nom wants to choose the optimal cell to start the walk from. That's why he wonders: for each possible starting cell, how many spiders will he see during the walk if he starts from this cell? Help him and calculate the required value for each possible starting cell.
Input Format
The first line contains three integers $ n,m,k $ $ (2
Output Format
Print $ m $ integers: the $ j $ -th integer must show the number of spiders Om Nom will see if he starts his walk from the $ j $ -th cell of the first row. The cells in any row of the field are numbered from left to right.
Explanation/Hint
Consider the first sample. The notes below show how the spider arrangement changes on the field over time:
`
... ... ..U ...
R.L -> .*U -> L.R -> ...
R.U .R. ..R ...
`Character "\*" represents a cell that contains two spiders at the same time. - If Om Nom starts from the first cell of the first row, he won't see any spiders. - If he starts from the second cell, he will see two spiders at time 1. - If he starts from the third cell, he will see two spiders: one at time 1, the other one at time 2.
... ... ..U ...
R.L -> .*U -> L.R -> ...
R.U .R. ..R ...
`Character "\*" represents a cell that contains two spiders at the same time. - If Om Nom starts from the first cell of the first row, he won't see any spiders. - If he starts from the second cell, he will see two spiders at time 1. - If he starts from the third cell, he will see two spiders: one at time 1, the other one at time 2.