Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

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


int main(){
    int h,w,lim;
    int cnt=1;
    pair<int,int> st;
    pair<int,int> gl;
    cin >> h >> w >> lim;
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--;y1--;x2--;y2--;

    st.first=x1;st.second=y1;
    gl.first=x2;gl.second=y2;

    vector<vector<char>>maze(h,vector<char>(w));
    vector<vector<int>>cost(h,vector<int>(w,inf));
    for(int i = 0; i < h; i++){     //迷路の入力
        for(int j = 0; j < w; j++){
            char c;
            cin >> c;
            maze[i][j] = c;
        }
    }
    cost[x1][y1]=0;
    queue<pair<int,int>> qe;
    qe.push(st);
    while(!qe.empty()){
        int x = qe.front().second;
        int y = qe.front().first;
        qe.pop();
        for(int k = 0;k < 4; k++){
            int nx = x+dx[k];
            int ny = y+dy[k];
            if(nx < 0 || nx >=w || ny < 0 || ny >= h) continue;
            if(maze[ny][nx] == '@') continue;
            if(cost[ny][nx] != inf) continue;
            if(k==0){
                if(y+1<h && maze[y+1][x]=='.' && cnt <=lim && cost[y+1][x]!=inf){
                    if(cnt ==lim){
                        cost[ny][nx]=cost[ny+lom][nx]+1;
                        cnt =1;
                    }
                    else{

                    
                    cost[ny][nx]=cost[ny+1][nx];
                    cnt++;
                    }
                }
                else{
                    cost[ny][nx]=cost[y][x]+1;
                    cnt=1;
                }
                qe.push(make_pair(ny,nx));
            }
            else if(k==1){
                if(x+1<w && maze[y][x+1]=='.' && cnt <=lim && cost[y][x+1]!=inf){
                    if(cnt==lim){
                        cost[ny][nx]=cost[ny][nx+lim]+1;
                        cnt =1;
                    }
                    else{
                        cost[ny][nx]=cost[ny][nx+1];
                        cnt ++;
                    }
                }
                else{
                    cost[ny][nx]=cost[y][x]+1;
                    cnt =1;
                }
                qe.push(make_pair(ny,nx));
            }
            else if(k==2){
                if(y-1>=0 && maze[y-1][x]=='.' && cnt <=lim && cost[y-1][x]!= inf){
                    if(cnt==lim){
                        cost[ny][nx]=cost[ny-lim][nx]+1;
                        cnt =1;
                    }
                    else{
                    cost[ny][nx]=cost[ny-1][nx];
                    cnt ++;
                    }
                }
                else{
                    cost[ny][nx]=cost[y][x]+1;
                    cnt =1;
                }
                qe.push(make_pair(ny,nx));
            }
            else if(k==3){
                if(x-1>=0 && maze[y][x-1]=='.' && cnt <=lim && cost[y][x-1] != inf){
                    if(cnt==lim){
                        cost[ny][nx]=cost[ny][nx-lim]+1;
                        cnt =1;
                    }
                    else{
                    cost[ny][nx]=cost[ny][nx-1];
                    cnt ++;
                    }
                }
                else{
                    cost[ny][nx]=cost[y][x]+1;
                    cnt =1;
                }
                qe.push(make_pair(ny,nx));
            }
        }
    }
    if(cost[gl.first][gl.second] != inf){
        cout <<cost[gl.first][gl.second] << endl;
    }
    else {
        cout << -1 <<endl;
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:46: error: 'lom' was not declared in this scope; did you mean 'lim'?
   53 |                         cost[ny][nx]=cost[ny+lom][nx]+1;
      |                                              ^~~
      |                                              lim