IntermediateRating 1300
Robot on a Grid
A robot on an r×c grid of . and # starts at the top-left facing right. It moves forward if the next cell is inside and free; otherwise it turns right (clockwise). Print the number of distinct cells visited after k actions (a move or a turn counts as one action).
Input
r c k, then r lines.
Output
A count.
Sample 1
Input
3 3 10 ... .#. ...
Output
8
Sample 2
Input
1 1 5 .
Output
1
Output appears here