static void init(int r, int c) {
        layout = new int[r][];
        for (int i = 0; i < r; ++i) {
            layout[i] = new int[c];
        }
        leastTime = new int[r][c];
        for (int i = 0; i < r; ++i) {
            leastTime[i] = new int[c];
            for (int j = 0; j < c; ++j) leastTime[i][j] = Integer.MAX_VALUE;
        }
        visited = new int[r][];
        for (int i = 0; i < r; ++i) {
            visited[i] = new int[c];
        }
    }