Language: C++

#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

struct Pos
{
  int i, j;
  void read() { scanf("%d %d", &i, &j); i--, j--; }
  bool operator==(const Pos &other) const { return i == other.i && j == other.j; }
};

int n, m, k;
Pos origin, destination;
vector<vector<char>> mat;

int manhattan(Pos pos)
{
  return abs(destination.i - pos.i) + abs(destination.j - pos.j);
}

struct Node
{
  int dist, hdist; Pos pos; int prvDir, combo;
  bool operator<(const Node &other) const { return hdist > other.hdist; }
  // bool operator<(const Node &other) const { return dist > other.dist; }
  void print() { printf("\t%d (%d, %d) %d %d\n", dist, pos.i, pos.j, prvDir, combo); }
};
int di[4] = {1, -1, 0, 0}, dj[4] = {0, 0, 1, -1};
vector<vector<vector<map<int, int>>>> dist;
int dijkstra()
{
  priority_queue<Node> pq;
  pq.push(Node{0, 0, origin, 4, 1});
  while (!pq.empty())
  {
    Node u = pq.top(); pq.pop();
    if (u.pos == destination) break;
    DEBUG u.print();
    if (!dist[u.pos.i][u.pos.j][u.prvDir].count(u.combo) && u.dist > dist[u.pos.i][u.pos.j][u.prvDir][u.combo])
      continue;

    for (int dir = 0; dir < 4; dir++)
    {
      Pos newPos = {u.pos.i + di[dir], u.pos.j + dj[dir]};
      if (newPos.i < 0 || newPos.i >= n || newPos.j < 0 || newPos.j >= m || mat[newPos.i][newPos.j] == '@') continue;
      int newDist = u.dist + (u.prvDir == dir && u.combo < k ? 0 : 1);
      int newCombo = dir == u.prvDir ? min(u.combo + 1, k) : 1;
      if (!dist[newPos.i][newPos.j][dir].count(newCombo) || newDist < dist[newPos.i][newPos.j][dir][newCombo])
      {
        dist[newPos.i][newPos.j][dir][newCombo] = newDist;
        pq.push(Node{newDist, newDist + manhattan(newPos), newPos, dir, newCombo});
      }
    }
  }
  int ans = 1e9;
  for (int i = 0; i < 5; i++)
    for (auto &hehe: dist[destination.i][destination.j][i])
      ans = min(ans, hehe.second);
  return ans == 1e9 ? -1 : ans;
}

int main()
{
  while (scanf("%d %d %d", &n, &m, &k) != EOF)
  {
    mat.clear();
    mat.resize(n, vector<char>(m));
    dist.clear();
    dist.resize(n, vector<vector<unordered_map<int, int>>>(m));
    origin.read(); destination.read();

    char line[m + 1];
    for (int i = 0; i < n; i++)
    {
      scanf(" %s", line);
      for (int j = 0; j < m; j++)
      {
        mat[i][j] = line[j];
        dist[i][j].resize(5);
      }
    }

    int ans = dijkstra();
    printf("%d\n", ans);
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:16: error: no matching function for call to 'std::vector<std::vector<std::vector<std::map<int, int> > > >::resize(int&, std::vector<std::vector<std::unordered_map<int, int> > >)'
   71 |     dist.resize(n, vector<vector<unordered_map<int, int>>>(m));
      |     ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1013:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(size_type) [with _Tp = std::vector<std::vector<std::map<int, int> > >; _Alloc = std::allocator<std::vector<std::vector<std::map<int, int> > > >; size_type = long unsigned int]'
 1013 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:1013:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:1034:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(size_type, const value_type&) [with _Tp = std::vector<std::vector<std::map<int, int> > >; _Alloc = std::allocator<std::vector<std::vector<std::map<int, int> > > >; size_type = long unsigned int; value_type = std::vector<std::vector<std::map<int, int> > >]'
 1034 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:1034:54: note:   no known conversion for argument 2 from 'std::vector<std::vector<std::unordered_map<int, int> > >' to 'const std::vector<std::vector<std::vector<std::map<int, int> > > >::value_type&' {aka 'const std::vector<std::vector<std::map<int, int> > >&'}
 1034 |       resize(size_type __new_size, const value_type& __x)
      |                                    ~~~~~~~~~~~~~~~~~~^~~