TopCoder problem "FireSimulation" used in TCHS07 Alpha 2 (Division I Level Three)

Problem Statement


You have a special model for simulating fire. It is a rectangular grid containing cells of equal size. Each cell contains a digit indicating how many minutes it takes for that cell to burn completely once it catches fire. After a cell is completely burned, the fire spreads to its vertically and horizontally adjacent cells.

You are given a String[] field, where the j-th character of the i-th element is the digit of the cell at row i, column j. At minute 0, the cell at row 0, column 0 catches fire. Return the state of the field at the given minute. The return value must be a String[] formatted exactly like field, but with '*' characters representing cells that are on fire and '.' characters representing cells that have burned completely.



Parameters:String[], int
Method signature:String[] getState(String[] field, int minute)
(be sure your method is public)


-field must contain between 1 and 10 elements, inclusive.
-Each element of field must contain between 1 and 10 characters, inclusive.
-Each element of field must contain the same number of characters.
-field must contain only digits between '1' and '9', inclusive.
-minute must be between 0 and 100, inclusive.


Returns: {"....*111" }
Returns: {"..*456789" }
{"111", "211", "311"}
Returns: {"..*", "**1", "311" }
At minute 0, it looks like this:
At minute 1, the cell at row 0, column 0 is burned completely and the two adjacent cells catch fire:
At minute 2, the cell at row 1, column 0 is still burning (it takes 2 minutes to burn completely). The cell at row 0, column 1 is burned completely and its adjacent cells catch fire. The cell at row 0, column 0 is an adjacent cell, but it's already completely burned, so it's not affected:

Problem url:

Problem stats url:


Mike Mirzayanov


PabloGilberto , brett1479 , Olexiy

Problem categories: