Language: C++

#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 

int dx[4] = {1,-1,0,0};
int dx[4] = {0,0,1,-1};

bool check(int x,int y,int n,int m)
{
  if(x < 0 || y < 0 || x >= n || y >= m) return false;
  return true;
}

void bfs(vector<string> &mat,pair<int,int> src,pair<int,int> dest,int k)
{
  int n = mat.size(), m = mat[0].size();
  queue<pair<int,int> > q;
  vector<vector<bool> > vis(n,vector<bool>(m));
  q.push(src);
  pair<int,int> NUL = mp(-1,-1);
  q.push(NUL);
  int ans = 0;
  while(!q.empty())
  {
    pair<int,int> p = q.front();
    q.pop();
    if(p == NUL)
    {
      if(q.empty()) break;
      else 
      {
        ans++;
        q.push(NUL);
      }
    }

    int x = p.fi, y = p.se;
    for(int i=0;i<4;i++)
    {
      bool flag = false;
      for(int j=1;j<=k;j++)
      {
        int a = x+dx[i]*j, b = y+dy[i]*j;
        if(!check(a,b,n,m) || vis[a][b]) {flag = true;break;}
        else 
        {
          vis[a][b] = true;
          q.push(mp(a,b));
        }
      }
    }
  }
  cout << ans << endl;
}

int main()
{
  __;
  int n,m,k;
  cin >> n >> m >> k;
  vector<string> mat(n);
  for(int i=0;i<n;i++) cin >> mat[i];
  pair<int,int> src,dest;
  cin >> src.fi >> src.se >> dest.fi >> dest.se;
  bfs(mat,src,dest);
  return 0;
}


Compiler output:
a.cc:31:5: error: redefinition of 'int dx [4]'
   31 | int dx[4] = {0,0,1,-1};
      |     ^~
a.cc:30:5: note: 'int dx [4]' previously defined here
   30 | int dx[4] = {1,-1,0,0};
      |     ^~
a.cc: In function 'void bfs(std::vector<std::__cxx11::basic_string<char> >&, std::pair<int, int>, std::pair<int, int>, int)':
a.cc:68:34: error: 'dy' was not declared in this scope; did you mean 'y'?
   68 |         int a = x+dx[i]*j, b = y+dy[i]*j;
      |                                  ^~
      |                                  y
a.cc: In function 'int main()':
a.cc:90:6: error: too few arguments to function 'void bfs(std::vector<std::__cxx11::basic_string<char> >&, std::pair<int, int>, std::pair<int, int>, int)'
   90 |   bfs(mat,src,dest);
      |   ~~~^~~~~~~~~~~~~~
a.cc:39:6: note: declared here
   39 | void bfs(vector<string> &mat,pair<int,int> src,pair<int,int> dest,int k)
      |      ^~~