Language: C++

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>

#define INF 100
using namespace std;
struct data{
	int x,y,p,q,dir;
	data(){}
	data(int yy,int xx,int dd,int pp,int qq){
		x=xx;
		y=yy;
		p=pp;
		q=qq;
		dir=dd;
	}
	bool operator<(const data &d)const{
		return q>d.q;
	}
};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int n,m,a;
int fie[101][101];
int dp[101][101][4][11];
int sx,sy,gx,gy;

int dijk(){
	int res=INF;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			for(int k=0;k<4;k++){
				for(int l=0;l<=a;l++){
					dp[i][j][k][l]=INF;
				}
			}
		}
	}
	priority_queue<data> que;
	que.push(data(sy,sx,1,0,0));
	dp[sy][sx][1][0]=0;
	while(que.size()){
		data q=que.top();
		que.pop();
		if(dp[q.y][q.x][q.dir][q.p]<q.q)continue;
		if(0<=q.x+dx[q.dir] && q.x+dx[q.dir]<m && 0<=q.y+dy[q.dir] && q.y+dy[q.dir]<n){
			if(fie[q.y+dy[q.dir]][q.x+dx[q.dir]]!=-1 && dp[q.y+dy[q.dir]][q.x+dx[q.dir]][q.dir][q.p]>q.q){
				if(fie[q.y+dy[q.dir]][q.x+dx[q.dir]]==1 && dir==2)continue;
				dp[q.y+dy[q.dir]][q.x+dx[q.dir]][q.dir][q.p]=q.q;
				que.push(data(q.y+dy[q.dir],q.x+dx[q.dir],q.dir,q.p,q.q));
			}
		}
		if(q.p<a){
			int ndir=-1;
			if(q.dir==0)ndir=3;
			if(q.dir==1)ndir=2;
			if(q.dir==2)ndir=1;
			if(q.dir==3)ndir=0;
			if(fie[q.y][q.x]==0 && dp[q.y][q.x][ndir][q.p+1]>q.q){
				dp[q.y][q.x][ndir][q.p+1]=q.q;
				que.push(data(q.y,q.x,ndir,q.p+1,q.q));
			}
		}
		if(q.q<a){
			int ndir=-1;
			if(q.dir==0)ndir=1;
			if(q.dir==1)ndir=0;
			if(q.dir==2)ndir=3;
			if(q.dir==3)ndir=2;
			if(fie[q.y][q.x]==0 && dp[q.y][q.x][ndir][q.p]>q.q+1){
				dp[q.y][q.x][ndir][q.p]=q.q+1;
				que.push(data(q.y,q.x,ndir,q.p,q.q+1));
			}
		}
	}
	for(int i=0;i<=a;i++){
		for(int j=0;j<4;j++){
			res=min(res,dp[gy][gx][j][i]+i);
		}
	}
	return res!=INF?res:-1;
}

int main(void){
	scanf("%d %d %d %d",&n,&m,&a);
	for(int i=0;i<n;i++){
		string str;
		cin >> str;
		for(int j=0;j<m;j++){
			if(str[j]=='S')sx=j,sy=i,fie[i][j]=1;
			if(str[j]=='G')gx=j,gy=i,fie[i][j]=2;
			if(str[j]=='#')fie[i][j]=-1;
		}
	}
	printf("%d\n",dijk());
	return 0;
}

Compiler output:
a.cc: In function 'int dijk()':
a.cc:42:28: error: template argument 1 is invalid
   42 |         priority_queue<data> que;
      |                            ^
a.cc:42:28: error: template argument 2 is invalid
a.cc:42:28: error: template argument 3 is invalid
a.cc:43:13: error: request for member 'push' in 'que', which is of non-class type 'int'
   43 |         que.push(data(sy,sx,1,0,0));
      |             ^~~~
a.cc:43:18: error: reference to 'data' is ambiguous
   43 |         que.push(data(sy,sx,1,0,0));
      |                  ^~~~
In file included from /usr/include/c++/14/string:53,
                 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:3:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:10:8: note:                 'struct data'
   10 | struct data{
      |        ^~~~
a.cc:45:19: error: request for member 'size' in 'que', which is of non-class type 'int'
   45 |         while(que.size()){
      |                   ^~~~
a.cc:46:17: error: reference to 'data' is ambiguous
   46 |                 data q=que.top();
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:10:8: note:                 'struct data'
   10 | struct data{
      |        ^~~~
a.cc:47:21: error: request for member 'pop' in 'que', which is of non-class type 'int'
   47 |                 que.pop();
      |                     ^~~
a.cc:48:23: error: 'q' was not declared in this scope
   48 |                 if(dp[q.y][q.x][q.dir][q.p]<q.q)continue;
      |                       ^
a.cc:49:23: error: 'q' was not declared in this scope
   49 |                 if(0<=q.x+dx[q.dir] && q.x+dx[q.dir]<m && 0<=q.y+dy[q.dir] && q.y+dy[q.dir]<n){
      |                       ^
a.cc:51:76: error: 'dir' was not declared in this scope; did you mean 'div'?
   51 |                                 if(fie[q.y+dy[q.dir]][q.x+dx[q.dir]]==1 && dir==2)continue;
      |                                                                            ^~~
      |                                                                            div
a.cc:53:37: error: request for member 'push' in 'que', which is of non-class type 'int'
   53 |                                 que.push(data(q.y+dy[q.dir],q.x+dx[q.dir],q.dir,q.p,q.q));
      |                                     ^~~~
a.cc:53:42: error: reference to 'data' is ambiguous
   53 |                                 que.push(data(q.y+dy[q.dir],q.x+dx[q.dir],q.dir,q.p,q.q));
      |                                          ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:10:8: note:                 'struct data'
   10 | struct data{
      |        ^~~~
a.cc:56:20: error: 'q' was not declared in this scope
   56 |                 if(q.p<a){
      |                    ^
a.cc:64:37: error: request for member 'push' in 'que', which is of non-class type 'int'
   64 |                                 que.push(data(q.y,q.x,ndir,q.p+1,q.q));
      |                                     ^~~~
a.cc:64:42: error: reference to 'data' is ambiguous
   64 |                                 que.push(data(q.y,q.x,ndir,q.p+1,q.q));
      |                                          ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:10:8: note:                 'struct data'
   10 | struct data{
      |        ^~~~
a.cc:67:20: error: 'q' was not declared in this scope
   67 |                 if(q.q<a){
      |                    ^
a.cc:75:37: error: request for member 'push' in 'que', which is of non-class type 'int'
   75 |                                 que.push(data(q.y,q.x,ndir,q.p,q.q+1));
      |                                     ^~~~
a.cc:75:42: error: reference to 'data' is ambiguous
   75 |                                 que.push(data(q.y,q.x,ndir,q.p,q.q+1));
      |                                          ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:10:8: note:                 'struct data'
   10 | struct data{
      |        ^~~~