Language: C++

int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	int x1, y1, x2, y2;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	char maze[h][w];
	int dis[h][w];
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			scanf(" %c", &maze[i][j]);
			dis[i][j] = INT_MAX;
		}
	}
	x1--;
	y1--;
	x2--;
	y2--;
 
	const int dir[4][2] = {{-1,0}, {0,-1}, {1,0}, {0,1}};
	queue<pair<int, int> > q;
	dis[x1][y1] = 0;
	q.push({x1, y1});
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
 
		for (int i=0; i<4; i++) {
			int nx = x;
			int ny = y;
			int nd = dis[x][y]+1;
			for (int j=1; j<=k; j++) {
				nx += dir[i][0];
				ny += dir[i][1];
 
				if (nx<0 || nx>=h || ny<0 || ny>=w || '@'==maze[nx][ny] || dis[nx][ny]<nd) {
					break;
				}
				if (dis[nx][ny]>nd) {
					dis[nx][ny] = nd;
					q.push({nx, ny});
				}
			}
		}
	}
 
	int ans = dis[x2][y2];
	printf("%d\n", (INT_MAX==ans ? -1 : ans));
 
	return 0;
}


Compiler output:
a.cc:2:14: error: expected constructor, destructor, or type conversion before '(' token
    2 |         scanf("%d%d%d", &h, &w, &k);
      |              ^
a.cc:3:17: warning: built-in function 'y1' declared as non-function [-Wbuiltin-declaration-mismatch]
    3 |         int x1, y1, x2, y2;
      |                 ^~
a.cc:4:14: error: expected constructor, destructor, or type conversion before '(' token
    4 |         scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
      |              ^
a.cc:5:22: error: size of array 'maze' is not an integral constant-expression
    5 |         char maze[h][w];
      |                      ^
a.cc:5:19: error: size of array 'maze' is not an integral constant-expression
    5 |         char maze[h][w];
      |                   ^
a.cc:6:20: error: size of array 'dis' is not an integral constant-expression
    6 |         int dis[h][w];
      |                    ^
a.cc:6:17: error: size of array 'dis' is not an integral constant-expression
    6 |         int dis[h][w];
      |                 ^
a.cc:7:9: error: expected unqualified-id before 'for'
    7 |         for (int i=0; i<h; i++) {
      |         ^~~
a.cc:7:23: error: 'i' does not name a type
    7 |         for (int i=0; i<h; i++) {
      |                       ^
a.cc:7:28: error: 'i' does not name a type
    7 |         for (int i=0; i<h; i++) {
      |                            ^
a.cc:13:9: error: 'x1' does not name a type
   13 |         x1--;
      |         ^~
a.cc:14:9: error: 'y1' does not name a type
   14 |         y1--;
      |         ^~
a.cc:15:9: error: 'x2' does not name a type
   15 |         x2--;
      |         ^~
a.cc:16:9: error: 'y2' does not name a type
   16 |         y2--;
      |         ^~
a.cc:19:9: error: 'queue' does not name a type
   19 |         queue<pair<int, int> > q;
      |         ^~~~~
a.cc:20:9: error: 'dis' does not name a type
   20 |         dis[x1][y1] = 0;
      |         ^~~
a.cc:21:9: error: 'q' does not name a type
   21 |         q.push({x1, y1});
      |         ^
a.cc:21:24: error: expected unqualified-id before ')' token
   21 |         q.push({x1, y1});
      |                        ^
a.cc:22:9: error: expected unqualified-id before 'while'
   22 |         while (!q.empty()) {
      |         ^~~~~
a.cc:47:15: error: expected constructor, destructor, or type conversion before '(' token
   47 |         printf("%d\n", (INT_MAX==ans ? -1 : ans));
      |               ^
a.cc:49:9: error: expected unqualified-id before 'return'
   49 |         return 0;
      |         ^~~~~~
a.cc:50:1: error: expected declaration before '}' token
   50 | }
      | ^