Language: C++

#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
const int N=1e6+5;
struct node{
	int x,y,num,count,t;
}p,f;
int move[3][5];
queue<node> q;

int main(){
	int n,m,k,i,j,x1,x2,y1,y2,x,y;
	scanf("%d%d%d",&n,&m,&k);
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	int a[n+1][m+1];
	int visited[n+1][m+1];
	char c;
	
	move[1][1]=0;move[1][2]=1;move[1][3]=0;move[1][4]=-1;
	move[1][1]=-1;move[2][2]=0;move[2][4]=1;move[2][4]=0;
	
	for(i=1;i<=n;++i)
		for(j=1;j<=m;++j){
			cin>>c;
			if(c=='.') a[i][j]=1;
			else a[i][j]=0;
		}
	
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++) 
			visited[i][j]=0;
	f.x=x1,f.y=y1,f.count=1,f.num=0;f.t=0;
	visited[x1][y1]=true;
	q.push(f);
	
	while(!q.empty()){
		f=q.front();
		for(i=1;i<=4;++i){
			x=f.x+move[1][i];y=f.y+move[2][i];
			if(!visited[x][y] && a[x][y] && x>=1 && x<=n && y>=1 && y<=m){
				p.x=x;p.y=y;
				if(f.t==i || f.t==0){
					p.t=i;
					if(f.num>=k){
						p.num=1;p.count=f.count+1;
					}
					else{
						p.num=f.num+1;p.count=f.count;
					}
				}
				else{
					p.t=i;
					p.num=1;p.count=f.count+1;
				}
				q.push(p);
				visited[x][y]=true;
				if(x==x2 && y==y2){
					printf("%d",p.count);
					return 0;
				}
			}
		}
		q.pop();
	}
	
	printf("%d",-1);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: reference to 'move' is ambiguous
   20 |         move[1][1]=0;move[1][2]=1;move[1][3]=0;move[1][4]=-1;
      |         ^~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:9:5: note:                 'int move [3][5]'
    9 | int move[3][5];
      |     ^~~~
a.cc:20:22: error: reference to 'move' is ambiguous
   20 |         move[1][1]=0;move[1][2]=1;move[1][3]=0;move[1][4]=-1;
      |                      ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:9:5: note:                 'int move [3][5]'
    9 | int move[3][5];
      |     ^~~~
a.cc:20:35: error: reference to 'move' is ambiguous
   20 |         move[1][1]=0;move[1][2]=1;move[1][3]=0;move[1][4]=-1;
      |                                   ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:9:5: note:                 'int move [3][5]'
    9 | int move[3][5];
      |     ^~~~
a.cc:20:48: error: reference to 'move' is ambiguous
   20 |         move[1][1]=0;move[1][2]=1;move[1][3]=0;move[1][4]=-1;
      |                                                ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:9:5: note:                 'int move [3][5]'
    9 | int move[3][5];
      |     ^~~~
a.cc:21:9: error: reference to 'move' is ambiguous
   21 |         move[1][1]=-1;move[2][2]=0;move[2][4]=1;move[2][4]=0;
      |         ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:9:5: note:                 'int move [3][5]'
    9 | int move[3][5];
      |     ^~~~
a.cc:21:23: error: reference to 'move' is ambiguous
   21 |         move[1][1]=-1;move[2][2]=0;move[2][4]=1;move[2][4]=0;
      |                       ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:9:5: note:                 'int move [3][5]'
    9 | int move[3][5];
      |     ^~~~
a.cc:21:36: error: reference to 'move' is ambiguous
   21 |         move[1][1]=-1;move[2][2]=0;move[2][4]=1;move[2][4]=0;
      |                                    ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:9:5: note:                 'int move [3][5]'
    9 | int move[3][5];
      |     ^~~~
a.cc:21:49: error: reference to 'move' is ambiguous
   21 |         move[1][1]=-1;move[2][2]=0;move[2][4]=1;move[2][4]=0;
      |                                                 ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:9:5: note:                 'int move [3][5]'
    9 | int move[3][5];
      |     ^~~~
a.cc:40:31: error: reference to 'move' is ambiguous
   40 |                         x=f.x+move[1][i];y=f.y+move[2][i];
      |                               ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:9:5: note:                 'int move [3][5]'
    9 | int move[3][5];
      |     ^~~~
a.cc:40:48: error: reference to 'move' is ambiguous
   40 |                         x=f.x+move[1][i];y=f.y+move[2][i];
      |                                                ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidates are: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:9:5: note:                 'int move [3][5]'
    9 | int move[3][5];
      |     ^~~~