Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main(){
  int H, W;cin>>H>>W;
  int L=W-1+(H-1)*W;
  vvi a;
  for (int i=0;i<H;++i){
    vi ai;
    for (int j=0;j<W;++j){
      int aij;cin>>aij;
      ai.push_back(aij);
    }
    a.push_back(ai);
  }

  vii path;
  ii position=make_pair(0,0);
  path.push_back(position);
  while(position.first<H&&position.second<W){
    if(position.first==H-1&&position.second%2==0){
      int x=position.second;
      position=make_pair(H-1, x+1);
      path.push_back(position);
    }
    else if(position.first==0&&position.second%2==1){
      int x=position.second;
      position=make_pair(0, x+1);
      path.push_back(position);
    }
    else if(position.second%2==0){
      int y=position.first;
      int x=position.second;
      position=make_pair(y+1, x);
      path.push_back(position);
    }
    else{
      int y=position.first;
      int x=position.second;
      position=make_pair(y-1, x);
      path.push_back(position);
    }
  }

  vector<ii, ii> move;
  int count=0;

  for(int n=0;n<L;i++){
    ii position = path[n];
    ii nxt_pos=path[n+1];
    int i=position.first;
    int j=position.second;
    int i_=nxt_pos.first;
    int j_=nxt_pos.second;
    if (a[i][j]%2==1){
      ii p=make_pair(i+1,j+1);
      ii q=make_pair(i_+1,j_+1);
      pair<ii, ii> r=make_pair(p,q);
      move.push_back(r);
      count++;
      a[i_][j_]++;
    }
  }

  cout << count << endl;

  for (int c=0;c<count;++c){
    ii p=move.first;
    ii q=move.second;
    int y=p.first;
    int x=p.second;
    int y_=q.first;
    int x_=q.second;
    cout << y<< x<< y_<< x_<< endl;
  }
  return 0;
}


Compiler output:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'struct std::_Vector_base<std::pair<int, int>, std::pair<int, int> >':
/usr/include/c++/14/bits/stl_vector.h:428:11:   required from 'class std::vector<std::pair<int, int>, std::pair<int, int> >'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
a.cc:50:18:   required from here
   50 |   vector<ii, ii> move;
      |                  ^~~~
/usr/include/c++/14/bits/stl_vector.h:87:28: error: no type named 'value_type' in 'struct std::pair<int, int>'
   87 |         rebind<_Tp>::other _Tp_alloc_type;
      |                            ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:89:9: error: no type named 'value_type' in 'struct std::pair<int, int>'
   89 |         pointer;
      |         ^~~~~~~
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'class std::vector<std::pair<int, int>, std::pair<int, int> >':
a.cc:50:18:   required from here
   50 |   vector<ii, ii> move;
      |                  ^~~~
/usr/include/c++/14/bits/stl_vector.h:518:20: error: '_M_allocate' has not been declared in 'std::vector<std::pair<int, int>, std::pair<int, int> >::_Base'
  518 |       using _Base::_M_allocate;
      |                    ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:519:20: error: '_M_deallocate' has not been declared in 'std::vector<std::pair<int, int>, std::pair<int, int> >::_Base'
  519 |       using _Base::_M_deallocate;
      |                    ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:521:20: error: '_M_get_Tp_allocator' has not been declared in 'std::vector<std::pair<int, int>, std::pair<int, int> >::_Base'
  521 |       using _Base::_M_get_Tp_allocator;
      |                    ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33:
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() [with _Tp = std::pair<int, int>; _Alloc = std::pair<int, int>]':
a.cc:50:18:   required from here
   50 |   vector<ii, ii> move;
      |                  ^~~~
/usr/include/c++/14/bits/stl_vector.h:136:24: error: no type named 'value_type' in 'struct std::pair<int, int>'
  136 |         _Vector_impl() _GLIBCXX_NOEXCEPT_IF(
      |                        ^~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:53:19: error: 'i' was not declared in this scope
   53 |   for(int n=0;n<L;i++){
      |                   ^
a.cc:64:21: error: no matching function for call to 'std::vector<std::pair<int, int>, std::pair<int, int> >::push_back(std::pair<std::pair<int, int>, std::pair<int, int> >&)'
   64 |       move.push_back(r);
      |       ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::pair<int, int>; value_type = std::pair<int, int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from 'std::pair<std::pair<int, int>, std::pair<int, int> >' to 'const std::vector<std::pair<int, int>, std::pair<int, int> >::value_type&' {aka 'const std::pair<int, int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::pair<int, int>; value_type = std::pair<int, int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from 'std::pair<std::pair<int, int>, std::pair<int, int> >' to 'std::vector<std::pair<int, int>, std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:73:15: error: 'class std::vector<std::pair<int, int>, std::pair<int, int> >' has no member named 'first'
   73 |     ii p=move.first;
      |               ^~~~~
a.cc:74:15: error: 'class std::vector<std::pair<int, int>, std::pair<int, int> >' has no member named 'second'
   74 |     ii q=move.second;
      |               ^~~~~~
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() [with _Tp = std::pair<int, int>; _Alloc = std::pair<int, int>]':
/usr/include/c++/14/bits/stl_vector.h:314:7:   required from here
  314 |       _Vector_base() = default;
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:141:26: error: no type named 'value_type' in 'struct std::pair<int, int>'
  141 |         : _Tp_alloc_type()
      |                          ^