8bool passable(vector<vector<int>> planks,
int start_row,
int start_column,
int row_size,
int column_size) {
9 if (0 <= start_row && start_row <= row_size-1 &&
10 0 <= start_column && start_column <= column_size-1) {
11 if (planks[start_row][start_column]) {
12 if (start_column == column_size-1) {
21 planks[start_row][start_column] = 0;
24 passable(planks, start_row, start_column + 1, row_size, column_size) ||
25 passable(planks, start_row + 1, start_column, row_size, column_size) ||
26 passable(planks, start_row - 1, start_column, row_size, column_size) ||
27 passable(planks, start_row, start_column - 1, row_size, column_size));
29 planks[start_row][start_column] = 1;
43 file_input.open(file_path.c_str());
44 if (file_input.fail()) {
48 getline(file_input, row_column);
49 istringstream line_row_column(row_column);
50 int num_row, num_column;
51 line_row_column >> num_row >> num_column;
53 vector<vector<int>> row(num_row, vector<int>(num_column));
54 for (
int i = 0; i < num_row; i++) {
56 getline(file_input, line);
57 istringstream line_in(line);
58 for (
int j = 0; j < num_column; j++) {
62 for (
int first_row = 0; first_row < num_row; first_row++) {
63 if (
passable(row, first_row, 0, num_row, num_column)) {
bool passable(vector< vector< int > > planks, int start_row, int start_column, int row_size, int column_size)