Language: C++

#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod


int main(){
    ll H,W,K; cin>>H>>W>>K;
    ll s[2], g[2];
    rep(i,2) {cin>>s[i]; s[i]--;}
    rep(i,2) {cin>>g[i]; g[i]--;}
    mat ans(H,vec(W,-INF));
    vector<vector<bool>> arrived(H,vector<bool>(W,false));
    queue<P> Q;
    const ll MAXN=1000010;
    rep(i,H){
        string S; cin>>S;
        rep(j,W) if(S[j]=='.') ans[i][j]=INF;
    }
    Q.push(mp(0,s[0]*MAXN+s[1]));
    ans[s[0]][s[1]]=0;
    //cout<<"arrived"<<endl;
    while(!Q.empty()){
        ll h=Q.front().second/MAXN, w=Q.front().second%MAXN;
        ll A=Q.front().first;
        Q.pop();
        if(h==g[0] && w==g[1]) break;
        if(!arrived[h][w]){
            arrived[h][w]=true;
            ll hh=min(H-1,h+K-1);
            while(true){
                if(abs(hh-h)==0) break;
                if(ans[hh][w]<0) break;
                if(ans[hh][w]>A+1){
                    ans[hh][w]=A+1;
                    Q.push(mp(A+1,hh*MAXN+w));
                }
                hh--;
            }
            hh=max(0,h-K+1);
            while(hh>=0){
                if(abs(hh-h)==0) break;
                if(ans[hh][w]<0) break;
                if(ans[hh][w]>A+1){
                    ans[hh][w]=A+1;
                    Q.push(mp(A+1,hh*MAXN+w));
                }
                hh++;
            }
            ll ww=min(w+K-1,W-1);
            while(true){
                if(abs(ww-w)==0) break;
                if(ans[h][ww]<0) break;
                if(ans[h][ww]>A+1){
                    ans[h][ww]=A+1;
                    Q.push(mp(A+1,h*MAXN+ww));
                }
                ww--;
            }
            ww=max(0,w-K+1);
            while(true){
                if(abs(ww-w)==0) break;
                if(ans[h][ww]<0) break;
                if(ans[h][ww]>A+1){
                    ans[h][ww]=A+1;
                    Q.push(mp(A+1,h*MAXN+ww));
                }
                ww++;
            }
        }
    }
    if(ans[g[0]][g[1]]<INF) cout<<ans[g[0]][g[1]]<<endl;
    else cout<<-1<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:19: error: no matching function for call to 'max(int, ll)'
   64 |             hh=max(0,h-K+1);
      |                ~~~^~~~~~~~~
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:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:64:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   64 |             hh=max(0,h-K+1);
      |                ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:64:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   64 |             hh=max(0,h-K+1);
      |                ~~~^~~~~~~~~
a.cc:84:19: error: no matching function for call to 'max(int, ll)'
   84 |             ww=max(0,w-K+1);
      |                ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:84:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   84 |             ww=max(0,w-K+1);
      |                ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:84:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   84 |             ww=max(0,w-K+1);
      |                ~~~^~~~~~~~~