Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
static const long long INF = 1000000;
using p = pair<int64_t,int64_t>;

//引数として２つのpをとって移動の可否、更には魔法の有無を調べる
int cost(p p1, p p2,vector<vector<char>> & road){
    if (p1 == p2){
        return -100;
    }
    else if (road[p1.first][p1.second] == '#' or road[p2.first][p2.second] == '#'){
        return -100;
    }
    else if (p1.first == p2.first and abs(p1.second - p2.second) < 2){
        return 0;
    }
    else if (p1.second == p2.second and abs(p1.first - p2.first) < 2){
        return 0;
    }
    else if (abs(p1.first - p2.first) < 3 and abs(p1.second - p2.second) < 3){
        return 1;
    }
    else{
        return -100;
    }
}


//ダイクストラのアルゴリズム
int dijkstra(int h,int w,int xs,int ys,int xg, int yg,vector<vector<char>> & road){
    int64_t min = INF;
    vector <vector<int>> color (h,vector<int> (w,0));
    vector <vector<int64_t>> d (h,vector<int64_t> (w,INF));
    d[xs][ys] = 0;
    //優先度を決める関数をラムダ式で記述する
    bool c = [&d](p cc, p ccc){
        if (d[cc.first][cc.second] < d[ccc.first][ccc.second]){
            return false;
        }
        else if(d[cc.first][cc.second] > d[ccc.first][ccc.second]){
            return true;
        }
        else if (cc.first > ccc.first){
            return true;
        }
        else if (cc.first < ccc.first){
            return false;
        }
        else if (cc.second > ccc.second){
            return true;
        }
        else {
            return false;
        }
        return false;
    };
    //優先度付きキューで高速化してみる

    priority_queue <p,vector<p>,decltype(c)> pq(c);
    rep(i,h){
        rep(j,w){
            p pe = {i,j};
            pq.push(pe);
        }
    }

    rep(a,w * h){
        min = INF;
        p u = {INF,INF};
    //キューが空欄でない限りdが一番小さい座標を取り出してその隣接点の情報を更新する
        if(!pq.empty()){
            u = pq.top();
            pq.pop();
            rep(i,h){    
                rep(j,w){
                    p pp = {i,j};
                    if (cost(u,pp,road) != -100 and d[pp.first][pp.second] > d[u.first][u.second] + cost(u,pp,road)){
                        d[pp.first][pp.second] = d[u.first][u.second] + cost(u,pp,road);
                    }
                }
            }
        }
    //キューが空欄ならループを終えてゴールの値を返す
        else if(d[xg][yg] == INF){
            return -1;
        }
        else {
            return d[xg][yg];
        }
        
    }
    return 0;
}


int main(){
    int h,w,xs,ys,xg,yg;
    cin >> h >> w >> xs >> ys >> xg >> yg;
    vector<vector<char>> road (h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin >> road[i][j];
        }
    }
    int k = dijkstra(h,w,xs-1,ys-1,xg-1,yg-1,road);
    cout << k << endl;
    
}


Compiler output:
a.cc: In function 'int dijkstra(int, int, int, int, int, int, std::vector<std::vector<char> >&)':
a.cc:37:14: error: cannot convert 'dijkstra(int, int, int, int, int, int, std::vector<std::vector<char> >&)::<lambda(p, p)>' to 'bool' in initialization
   37 |     bool c = [&d](p cc, p ccc){
      |              ^~~~~~~~~~~~~~~~~~
      |              |
      |              dijkstra(int, int, int, int, int, int, std::vector<std::vector<char> >&)::<lambda(p, p)>
   38 |         if (d[cc.first][cc.second] < d[ccc.first][ccc.second]){
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   39 |             return false;
      |             ~~~~~~~~~~~~~
   40 |         }
      |         ~     
   41 |         else if(d[cc.first][cc.second] > d[ccc.first][ccc.second]){
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   42 |             return true;
      |             ~~~~~~~~~~~~
   43 |         }
      |         ~     
   44 |         else if (cc.first > ccc.first){
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   45 |             return true;
      |             ~~~~~~~~~~~~
   46 |         }
      |         ~     
   47 |         else if (cc.first < ccc.first){
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   48 |             return false;
      |             ~~~~~~~~~~~~~
   49 |         }
      |         ~     
   50 |         else if (cc.second > ccc.second){
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   51 |             return true;
      |             ~~~~~~~~~~~~
   52 |         }
      |         ~     
   53 |         else {
      |         ~~~~~~
   54 |             return false;
      |             ~~~~~~~~~~~~~
   55 |         }
      |         ~     
   56 |         return false;
      |         ~~~~~~~~~~~~~
   57 |     };
      |     ~         
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<long int, long int>*, std::vector<std::pair<long int, long int> > >; _Value = std::pair<long int, long int>; _Compare = bool]':
/usr/include/c++/14/bits/stl_heap.h:140:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long int, long int>*, vector<pair<long int, long int> > >; _Distance = long int; _Tp = pair<long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool>]'
  140 |       while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:216:23:   required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<long int, long int>*, vector<pair<long int, long int> > >; _Compare = bool]'
  216 |       std::__push_heap(__first, _DistanceType((__last - __first) - 1),
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  217 |                        _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp);
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:739:16:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long int, long int>; _Sequence = std::vector<std::pair<long int, long int> >; _Compare = bool; value_type = std::pair<long int, long int>]'
  739 |         std::push_heap(c.begin(), c.end(), comp);
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:64:20:   required from here
   64 |             pq.push(pe);
      |             ~~~~~~~^~~~
/usr/include/c++/14/bits/predefined_ops.h:196:30: error: expression cannot be used as a function
  196 |         { return bool(_M_comp(*__it, __val)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<long int, long int>*, std::vector<std::pair<long int, long int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<long int, long int>*, std::vector<std::pair<long int, long int> > >; _Compare = bool]':
/usr/include/c++/14/bits/stl_heap.h:232:14:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long int, long int>*, vector<pair<long int, long int> > >; _Distance = long int; _Tp = pair<long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]'
  232 |           if (__comp(__first + __secondChild,
      |               ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
  233 |                      __first + (__secondChild - 1)))
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:356:22:   required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long int, long int>*, vector<pair<long int, long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]'
  356 |           std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value),
      |           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  357 |                              __comp);
      |                              ~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:413:23:   required from 'void std::make_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<long int, long int>*, vector<pair<long int, long int> > >; _Compare = bool]'
  413 |       std::__make_heap(__first, __last, __cmp);
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:565:23:   required from 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = std::pair<long int, long int>; _Sequence = std::vector<std::pair<long int, long int> >; _Compare = bool]'
  565 |       { std::make_heap(c.begin(), c.end(), comp); }
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:50:   required from here
   60 |     priority_queue <p,vector<p>,decltype(c)> pq(c);
      |                                                  ^
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: expression cannot be used as a function
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~