Language: C++

#include <stdio.h>
#include <algorithm>
#include <queue>
using namespace std;

struct phase{
	int x,y,d; pair<int, int> c;
  bool operator <(const phase &t) const{
    if (c.first == t.c.first) return c.second < t.c.second;
return c.first > t.c.first;
  }
};

int n,m,k;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
int sx,sy, ex,ey;

char map[10001001];
phase e[1001001][2];

priority_queue<phase> q;
void enque(int x, int y, int d, pair<int, int> c)
{
  phase p{x,y,d,c};
  if (e[x*m+y] < p){
e[x*m+y] = p;
    q.push(p);
  }
}

int main()
{
  scanf ("%d %d %d",&n,&m,&k);
  scanf ("%d %d %d %d",&sx,&sy,&ex,&ey);
  for (int i=0;i<n;i++) scanf ("%s",map+i*m);
  for (int i=0;i<n*m;i++) e[i][0] = e[i][1] = {0,0,0,{100000000, 0}};
enque(sx, sy, 0, {0,0});
enque(sx, sy, 1, {0,0});
  while (!Q.empty()){
int x = Q.top().x;
int y = Q.top().y;
int d = Q.top().d;
    auto c = Q.top().c;
    Q.pop();
    
    if (e[x*m+y].c != c) continue;
    for (int k=0;k<4;k++){
int px= x+dx[k];
      int py = y + dy[k];
      if (px < 0 || px >= n || py < 0 || py >= m || map[px*m+py] == '@') continue;
      enque(px,py,k%2,{c.first+1,K-1});
      if (c.second && k % 2 == d){
      enque(px,py,k%2,{c.first,c.second-1});
      }
    }
  }
  
  int ans = min(e[ex*m+ey][0].c.first,e[ex*m+ey][1].c.first);
  if (ans == 100000000) ans = -1;
  printf ("%d\n",ans);
  
 return 0; 
}

Compiler output:
a.cc: In function 'void enque(int, int, int, std::pair<int, int>)':
a.cc:26:16: error: no match for 'operator<' (operand types are 'phase [2]' and 'phase')
   26 |   if (e[x*m+y] < p){
      |       ~~~~~~~~ ^ ~
      |              |   |
      |              |   phase
      |              phase [2]
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1045 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
a.cc:26:18: note:   mismatched types 'const std::pair<_T1, _T2>' and 'phase [2]'
   26 |   if (e[x*m+y] < p){
      |                  ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  448 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
a.cc:26:18: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'phase [2]'
   26 |   if (e[x*m+y] < p){
      |                  ^
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  493 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
a.cc:26:18: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'phase [2]'
   26 |   if (e[x*m+y] < p){
      |                  ^
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1694 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note:   template argument deduction/substitution failed:
a.cc:26:18: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'phase [2]'
   26 |   if (e[x*m+y] < p){
      |                  ^
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1760 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note:   template argument deduction/substitution failed:
a.cc:26:18: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'phase [2]'
   26 |   if (e[x*m+y] < p){
      |                  ^
In file included from /usr/include/c++/14/deque:66,
                 from /usr/include/c++/14/queue:62,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_deque.h:2334:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<(const deque<_Tp, _Alloc>&, const deque<_Tp, _Alloc>&)'
 2334 |     operator<(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:2334:5: note:   template argument deduction/substitution failed:
a.cc:26:18: note:   mismatched types 'const std::deque<_Tp, _Alloc>' and 'phase [2]'
   26 |   if (e[x*m+y] < p){
      |                  ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/deque:81:
/usr/include/c++/14/tuple:2600:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
 2600 |     operator<(const tuple<_TElements...>& __t,
      |     ^~~~~~~~
/usr/include/c++/14/tuple:2600:5: note:   template argument deduction/substitution failed:
a.cc:26:18: note:   mismatched types 'const std::tuple<_UTypes ...>' and 'phase [2]'
   26 |   if (e[x*m+y] < p){
      |                  ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/queue:63:
/usr/include/c++/14/bits/stl_vector.h:2089:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)'
 2089 |     operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:2089:5: note:   template argument deduction/substitution failed:
a.cc:26:18: note:   mismatched types 'const std::vector<_Tp, _Alloc>' and 'phase [2]'
   26 |   if (e[x*m+y] < p){
      |                  ^
In file included from /usr/include/c++/14/queue:66:
/usr/include/c++/14/bits/stl_queue.h:397:5: note: candidate: 'template<class _Tp, class _Seq> bool std::operator<(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&)'
  397 |     operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:397:5: note:   template argument deduction/substitution failed:
a.cc:26:18: note:   mismatched types 'const std::queue<_Tp, _Seq>' and 'phase [2]'
   26 |   if (e[x*m+y] < p){
      |                  ^
a.cc:27:10: error: incompatible types in assignment of 'phase' to 'phase [2]'
   27 | e[x*m+y] = p;
      | ~~~~~~~~~^~~
a.cc: In function 'int main()':
a.cc:40:11: error: 'Q' was not declared in this scope
   40 |   while (!Q.empty()){
      |           ^
a.cc:47:18: error: request for member 'c' in 'e[((x * m) + y)]', which is of non-class type 'phase [2]'
   47 |     if (e[x*m+y].c != c) continue;
      |                  ^
a.cc:52:34: error: 'K' was not declared in this scope
   52 |       enque(px,py,k%2,{c.first+1,K-1});
      |                                  ^
a.cc:52:12: error: could not convert '{<expression error>, <expression error>}' from '<brace-enclosed initializer list>' to 'std::pair<int, int>'
   52 |       enque(px,py,k%2,{c.first+1,K-1});
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            |
      |            <brace-enclosed initializer list>
a.cc:54:12: error: could not convert '{<expression error>, <expression error>}' from '<brace-enclosed initializer list>' to 'std::pair<int, int>'
   54 |       enque(px,py,k%2,{c.first,c.second-1});
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            |
      |            <brace-enclosed initializer list>