public void solve(char[][] board) {
        m = board.length;
        if (m == 0)
            return;
        n = board[0].length;
        visited = new boolean[m + 2][n + 2];
        for (int i = 0; i < m; i++)
            for (int j = 0; j < n; j++)
                if (board[i][j] == 'X')
                    visited[i + 1][j + 1] = true;

        dfs();

        for (int i = 0; i < m; i++)
            for (int j = 0; j < n; j++)
                if (!visited[i + 1][j + 1])
                    board[i][j] = 'X';
    }