Language: C++

1 5
9 9 9 9 9#include <bits/stdc++.h>
using namespace std;
int H, W;
vector<vector<int> > path;

void move(int i, int j, bool right) {
  if (right) {
    if (j < (W-1)) {
      vector<int> v{i+1, j+1, i+1, j+2};
      path.push_back(v);
    } else if (i < (H-1)) {
      vector<int> v{i+1, j+1, i+2, j+1};
      path.push_back(v);
    }
  } else {
    if (j > 0) {
      vector<int> v{i+1, j+1, i+1, j};
      path.push_back(v);
    } else if (i < (H-1)) {
      vector<int> v{i+1, j+1, i+2, j+1};
    }
  }
}

bool check(vector<vector<int> >A, int i, int j, bool odd, bool right) {
  if (odd && A[i][j] % 2 == 0) {
    move(i, j, right);
  } else if (!odd && A[i][j] % 2 != 0) {
    move(i, j, right);
    odd = true;
  } else if (odd && A[i][j] % 2 != 0) {
    odd = false;
  }
  return odd;
}

int main() {
  cin >> H >> W;
  vector<vector<int> > A(H, vector<int>(W));
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> A[i][j];
    }
  }
  bool odd = false;
  for (int i=0; i<H; i++) {
    if (i % 2 == 0) {
      for (int j=0; j<W; j++) {
        odd = check(A, i, j, odd, true);
      }
    } else {
      for (int j=W-1; j>=0; j--) {
        odd = check(A, i, j, odd, false);
      }
    }
  }
  cout << path.size() << endl;
  for (auto v: path) {
    cout << v[0] << " " << v[1] << " " << v[2] << " " << v[3] << endl;
  }
}

Compiler output:
a.cc:2:10: error: stray '#' in program
    2 | 9 9 9 9 9#include <bits/stdc++.h>
      |          ^
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 1 5
      | ^
a.cc:5:1: error: 'vector' does not name a type
    5 | vector<vector<int> > path;
      | ^~~~~~
a.cc: In function 'void move(int, int, bool)':
a.cc:10:7: error: 'vector' was not declared in this scope
   10 |       vector<int> v{i+1, j+1, i+1, j+2};
      |       ^~~~~~
a.cc:10:14: error: expected primary-expression before 'int'
   10 |       vector<int> v{i+1, j+1, i+1, j+2};
      |              ^~~
a.cc:11:7: error: 'path' was not declared in this scope
   11 |       path.push_back(v);
      |       ^~~~
a.cc:11:22: error: 'v' was not declared in this scope
   11 |       path.push_back(v);
      |                      ^
a.cc:13:7: error: 'vector' was not declared in this scope
   13 |       vector<int> v{i+1, j+1, i+2, j+1};
      |       ^~~~~~
a.cc:13:14: error: expected primary-expression before 'int'
   13 |       vector<int> v{i+1, j+1, i+2, j+1};
      |              ^~~
a.cc:14:7: error: 'path' was not declared in this scope
   14 |       path.push_back(v);
      |       ^~~~
a.cc:14:22: error: 'v' was not declared in this scope
   14 |       path.push_back(v);
      |                      ^
a.cc:18:7: error: 'vector' was not declared in this scope
   18 |       vector<int> v{i+1, j+1, i+1, j};
      |       ^~~~~~
a.cc:18:14: error: expected primary-expression before 'int'
   18 |       vector<int> v{i+1, j+1, i+1, j};
      |              ^~~
a.cc:19:7: error: 'path' was not declared in this scope
   19 |       path.push_back(v);
      |       ^~~~
a.cc:19:22: error: 'v' was not declared in this scope
   19 |       path.push_back(v);
      |                      ^
a.cc:21:7: error: 'vector' was not declared in this scope
   21 |       vector<int> v{i+1, j+1, i+2, j+1};
      |       ^~~~~~
a.cc:21:14: error: expected primary-expression before 'int'
   21 |       vector<int> v{i+1, j+1, i+2, j+1};
      |              ^~~
a.cc: At global scope:
a.cc:26:12: error: 'vector' was not declared in this scope
   26 | bool check(vector<vector<int> >A, int i, int j, bool odd, bool right) {
      |            ^~~~~~
a.cc:26:19: error: 'vector' was not declared in this scope
   26 | bool check(vector<vector<int> >A, int i, int j, bool odd, bool right) {
      |                   ^~~~~~
a.cc:26:26: error: expected primary-expression before 'int'
   26 | bool check(vector<vector<int> >A, int i, int j, bool odd, bool right) {
      |                          ^~~
a.cc:26:35: error: expected primary-expression before 'int'
   26 | bool check(vector<vector<int> >A, int i, int j, bool odd, bool right) {
      |                                   ^~~
a.cc:26:42: error: expected primary-expression before 'int'
   26 | bool check(vector<vector<int> >A, int i, int j, bool odd, bool right) {
      |                                          ^~~
a.cc:26:49: error: expected primary-expression before 'bool'
   26 | bool check(vector<vector<int> >A, int i, int j, bool odd, bool right) {
      |                                                 ^~~~
a.cc:26:59: error: expected primary-expression before 'bool'
   26 | bool check(vector<vector<int> >A, int i, int j, bool odd, bool right) {
      |                                                           ^~~~
a.cc:26:69: error: expression list treated as compound expression in initializer [-fpermissive]
   26 | bool check(vector<vector<int> >A, int i, int j, bool odd, bool right) {
      |                                                                     ^
a.cc: In function 'int main()':
a.cc:39:3: error: 'cin' was not declared in this scope
   39 |   cin >> H >> W;
      |   ^~~
a.cc:40:3: error: 'vector' was not declared in this scope
   40 |   vector<vector<int> > A(H, vector<int>(W));
      |   ^~~~~~
a.cc:40:17: error: expected primary-expression before 'int'
   40 |   vector<vector<int> > A(H, vector<int>(W));
      |                 ^~~
a.cc:43:14: error: 'A' was not declared in this scope
   43 |       cin >> A[i][j];
      |              ^
a.cc:50:21: error: 'A' was not declared in this scope
   50 |         odd = check(A, i, j, odd, true);
      |                     ^
a.cc:50:20: error: 'check' cannot be used as a function
   50 |         odd = check(A, i, j, odd, true);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:54:21: error: 'A' was not declared in this scope
   54 |         odd = check(A, i, j, odd, false);
      |                     ^
a.cc:54:20: error: 'check' cannot be used as a function
   54 |         odd = check(A, i, j, odd, false);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:58:3: error: 'cout' was not declared in this scope
   58 |   cout << path.size() << endl;
      |   ^~~~
a.cc:58:11: error: 'path' was not declared in this scope
   58 |   cout << path.size() << endl;
      |           ^~~~
a.cc:58:26: error: 'endl' was not declared in this scope
   58 |   cout << path.size() << endl;
      |                          ^~~~