FastPrepFastPrep
Problem Brief

Grid Infection with Immune Cells Until Stable

FULLTIMEPHONE SCREEN

Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem.

Problem

Extending the previous problem, the grid may also contain immune cells 'I':

'I' can never be infected.

'I' does not infect others (it is not counted as infected).

Each day (synchronously), any healthy '.' cell with at least T infected 'X' neighbors among its 8 neighbors becomes 'X'. 'I' always stays 'I'.

Return the number of days until the grid becomes stable (no new infections occur).

Example

Input

3 3

1

I..

.X.

...

Output

1

Function Description

Complete solveGridInfectionWithImmuneCells. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters.

1Example 1

Input
input = "3 3\n1\nI..\n.X.\n..."
Output
["1"]
Explanation

The returned string array must match the expected standard output lines for the sample input.

Constraints

Limits and guarantees your solution can rely on.

Use the limits and requirements stated in the prompt.

public String[] solveGridInfectionWithImmuneCells(String input) {
    // write your code here
}
Input

input

"3 3\n1\nI..\n.X.\n..."

Output

["1"]

Sign in to submit your solution.