Language: C++

/*---------------------------------------------*/
/*
    ABC176 D
 */
/*---------------------------------------------*/

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

const int64_t INF = 0x3fffffffffffffff;

int64_t search2 ( int64_t h, int64_t w,
             int64_t ch, int64_t cw,
             int64_t dh, int64_t dw, std::vector<string> s ) {
    std::vector<std::vector<int64_t> > pos_cost( h, std::vector<int64_t>(w, INF) );
    pos_cost[ch][cw] = 0;
    deque<pair<int64_t, int64_t> > q;
    q.emplace_front( make_pair(ch, cw) );
    while ( !q.empty() ) {
        int64_t current_h = q.front().first;
        int64_t current_w = q.front().second;
        q.pop_front();
        // if ( s[current_h][current_w] == '#' ) continue;
        int64_t cost = pos_cost[current_h][current_w];
        int64_t hh[] = {-1, 0, 1, 0};
        int64_t ww[] = {0, -1, 0, 1};
        rep(i, 4) {
            int64_t sh = current_h+hh[i];
            int64_t sw = current_w+ww[i];
            if ( 0 <= sh && sh <= h-1 && 0 <= sw && sw <= w-1 ) {
                if ( s[sh][sw] == '.' ) {
                    chmin(pos_cost[sh][sw], cost);
                    q.emplace_front( make_pair(ch, cw) );
                }
            }
        }

        repb(i, -2, 2) {
            repb(j, -2, 2) {
                int64_t sh = current_h+i;
                int64_t sw = current_w+j;
                if ( 0 <= sh && sh <= h-1 && 0 <= sw && sw <= w-1 ) {
                    if ( s[sh][sw] == '.' ) {
                        if ( pos_cost[sh][sw] > cost+1 ) {
                            pos_cost[sh][sw] = cost+1;
                            q.emplace_back( make_pair(ch, cw) );
                        }
                        // chmin(pos_cost[sh][sw], cost+1);
                    }
                }
            }
        }
    }
    int64_t ans = pos_cost[dh][dw];
    if ( ans == INF) ans = -1;
    return ans;
}

int main() {
    int64_t h, w;cin >> h >> w;
    int64_t ch, cw;cin >> ch >> cw;
    int64_t dh, dw;cin >> dh >> dw;
    ch--;cw--;dh--;dw--;
    std::vector<string> s;
    int64_t alldot = 1;
    rep(i, h) cin >> s[i];

    int64_t ans = 0;
    if (!alldot) {
        ans = search(h, w, ch, cw, dh, dw, s);
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:88:21: error: no matching function for call to 'search(int64_t&, int64_t&, int64_t&, int64_t&, int64_t&, int64_t&, std::vector<std::__cxx11::basic_string<char> >&)'
   88 |         ans = search(h, w, ch, cw, dh, dw, s);
      |               ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_algobase.h:2332:5: note: candidate: 'template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> _ForwardIterator1 std::search(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _BinaryPredicate)'
 2332 |     search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
      |     ^~~~~~
/usr/include/c++/14/bits/stl_algobase.h:2332:5: note:   candidate expects 5 arguments, 7 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4090:5: note: candidate: 'template<class _FIter1, class _FIter2> _FIter1 std::search(_FIter1, _FIter1, _FIter2, _FIter2)'
 4090 |     search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
      |     ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:4090:5: note:   candidate expects 4 arguments, 7 provided
/usr/include/c++/14/bits/stl_algo.h:4184:5: note: candidate: 'template<class _ForwardIterator, class _Searcher> _ForwardIterator std::search(_ForwardIterator, _ForwardIterator, const _Searcher&)'
 4184 |     search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:4184:5: note:   candidate expects 3 arguments, 7 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:112:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::search(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _BinaryPredicate)'
  112 | search(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __s_first,
      | ^~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:112:1: note:   candidate expects 6 arguments, 7 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:117:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::search(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2)'
  117 | search(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __s_first,
      | ^~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:117:1: note:   candidate expects 5 arguments, 7 provided