Language: C++

#include <iostream>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <map>

using namespace std;


int solve(int h, int w, vector<vector<char> >& field, vector<pair<int, int> >& dot_vec, int n){
  /*
  cout << h << " " <<  w << " " << endl;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << field[i][j];
    }
    cout << endl;
  }
  */
  bool changed = false;
  vector< vector<char> > org_field = field;

  // for(int i = 0; i < h; i++){
  //   for(int j = 0; j < w; j++){
  //     if( field[i][j] == '.' ){
  //       if( (i > 0     && org_field[i - 1][j    ] == '#')  ||
  //           (i < h - 1 && org_field[i + 1][j    ] == '#')  || 
  //           (j > 0     && org_field[i    ][j - 1] == '#')  || 
  //           (j < w - 1 && org_field[i    ][j + 1] == '#') )
  //       {
  //         field[i][j] = '#';
  //         changed = true;
  //       }
  //     }
  //   }
  // }
  vector< pair<int,int> > new_dot_vec;
  for(auto vec : dot_vec){
    int i = vec.first;
    int j = vec.second;
    if( (i > 0     && org_field[i - 1][j    ] == '#')  ||
        (i < h - 1 && org_field[i + 1][j    ] == '#')  || 
        (j > 0     && org_field[i    ][j - 1] == '#')  || 
        (j < w - 1 && org_field[i    ][j + 1] == '#') )
    {
      field[i][j] = '#';
      changed = true;
    } else {
      new_dot_vec.push_back(make_pair<int, int>(i, j));
    }
  }

  if(changed){
    return solve(h, w, field, new_dot_vec, n + 1);
  } else {
    return n;
  }
}

int main(int argc, char const* argv[])
{
  int h, w;
  char c;
  vector<vector<char> > field;
  vector< pair<int,int> > dot_vec;

  cin >> h;
  cin >> w;


  for(int i = 0; i < h; i++){
    vector<char> row;
    for(int j = 0; j < w; j++){
      cin >> c;
      row.push_back(c);
      if(c == '.'){
        dot_vec.push_back(make_pair<int,int>(i, j));
      }
    }
    field.push_back(row);
  }

  cout << solve(h, w, field, dot_vec, 0);

  return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int, std::vector<std::vector<char> >&, std::vector<std::pair<int, int> >&, int)':
a.cc:50:49: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   50 |       new_dot_vec.push_back(make_pair<int, int>(i, j));
      |                                                 ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note:   initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |               ~~~~~~^~~
a.cc: In function 'int main(int, const char**)':
a.cc:78:46: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   78 |         dot_vec.push_back(make_pair<int,int>(i, j));
      |                                              ^
/usr/include/c++/14/bits/stl_pair.h:1132:21: note:   initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |               ~~~~~~^~~