Language: C++

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

void recdist(int i,
             int j,
             int h,
             int w,
             int **dist,
             int now_dist,
             deque<pair<int, int> > &bpoints,
             int &ret)
{
  if(i != 0 && dist[i - 1][j] > now_dist)
    {
      dist[i - 1][j] = now_dist;
      bpoints.push_back(make_pair<int, int>(i - 1, j));
      ret = std::max(now_dist, ret);
      //      recdist(i - 1, j, h, w, dist, now_dist + 1);
    }
  if((i + 1) != h && dist[i + 1][j] > now_dist)
    {
      dist[i + 1][j] = now_dist;
      bpoints.push_back(make_pair<int,int>(i + 1, j));
      ret = std::max(now_dist, ret);
      //      recdist(i + 1, j, h, w, dist, now_dist + 1);
    }
  if(j != 0 && dist[i][j - 1] > now_dist)
    {
      dist[i][j - 1] = now_dist;
      bpoints.push_back(make_pair<int,int>(i, j - 1));
      ret = std::max(now_dist, ret);
      //      recdist(i, j - 1, h, w, dist, now_dist + 1);
    }
  if((j + 1) != w && dist[i][j + 1] > now_dist)
    {
      dist[i][j + 1] = now_dist;
      bpoints.push_back(make_pair<int,int>(i, j + 1));
      ret = std::max(now_dist, ret);
      //      recdist(i, j + 1, h, w, dist, now_dist + 1);
    }
}

int main()
{
  int h,w;
  cin >> h >> w;
  char a[h][w];
  int **dist = new int*[h];
  deque<pair<int, int> > bpoints;
  for(int i = 0;
      i < h;
      ++i)
    {
      dist[i] = new int[w];
    }

  for(int i = 0;
      i < h;
      ++i)
    {
      for(int j = 0;
          j < w;
          ++j)
        {
          cin >> a[i][j];
          if(a[i][j] == '#')
            {
              dist[i][j] = 0;
            }
        }
    }


  for(int i = 0;
      i < h;
      ++i)
    {
      for(int j = 0;
          j < w;
          ++j)
        {
          if(a[i][j] == '#')
            {
              dist[i][j] = 0;
              bpoints.push_back(make_pair<int, int>(i,j));
            }
          else
            {
              dist[i][j] = 1000000;
            }
        }
    }
  int now_dist = 1;
  int bpoints_size = bpoints.size();
  int ret = 0;
  while(bpoints_size != 0)
    {
      for(int i = 0;
          i < bpoints_size;
        ++i)
        {
          recdist(bpoints.front().first,
                  bpoints.front().second,
                  h,
                  w,
                  dist,
                  now_dist,
                  bpoints,
                  ret);
          bpoints.pop_front();
        }
      ++now_dist;
      bpoints_size = bpoints.size();
    }
  cout << ret << endl;


  return 0;
}


Compiler output:
a.cc: In function 'void recdist(int, int, int, int, int**, int, std::deque<std::pair<int, int> >&, int&)':
a.cc:27:52: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   27 |       bpoints.push_back(make_pair<int, int>(i - 1, 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:32: note:   initializing argument 2 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:34:51: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   34 |       bpoints.push_back(make_pair<int,int>(i + 1, j));
      |                                                   ^
/usr/include/c++/14/bits/stl_pair.h:1132:32: note:   initializing argument 2 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:41:44: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   41 |       bpoints.push_back(make_pair<int,int>(i, j - 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:48:44: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   48 |       bpoints.push_back(make_pair<int,int>(i, j + 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()':
a.cc:96:53: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   96 |               bpoints.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)
      |               ~~~~~~^~~