195. Rotting Oranges
A grid holds oranges. Each cell is 0 for empty, 1 for a fresh orange, or
2 for a rotten one.
Every minute, a rotten orange rots any fresh orange directly above, below, left or right of it. Diagonals do not count.
Print how many minutes pass until no fresh orange remains, or -1 if some fresh orange can
never be reached.
Note that ALL rotten oranges spread at the same time, which is exactly what a queue gives you for free.
Constraints - `1 ≤ r, c ≤ 1000` - Each value is `0`, `1` or `2`.
Input
The first line contains two integers r and c, the number of rows and columns.
Each of the next r lines contains c space-separated integers, each 0, 1 or 2.
Output
Print one integer, the number of minutes until no fresh orange remains, or -1 if that never happens.
Print 0 if there are no fresh oranges to begin with.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.