Language: C++

#include <bits/stdc++.h>
using namespace std;
??
//h, w, dir, P, Q
typedef struct _State{
????????int h, w, dir;
????????vector<int> pq;
}State;
??
int N, M, A;
int Sh, Sw, Gh, Gw;
vector<string> field;
??
//south is 0
int dh[] = {1, -1, 0, 0};
int dw[] = {0, 0, 1, -1};
??
int table[2][4] = {{2, 3, 0, 1}, {3, 2, 1, 0}};
??
int dist[110][110][4][11][11];
??
int bfs(){
????????queue<State> que;
????????//map<State, int> dist;
????????memset(dist, -1, sizeof(dist));
????????State s = State({Sh, Sw, 0, {A, A}});
????????que.push(s);
????????dist[s.h][s.w][s.dir][s.pq[0]][s.pq[1]] = 0;
??????????
????????while(!que.empty()){
????????????????State u = que.front(); que.pop();
????????????????for(int nh=u.h+dh[u.dir], nw=u.w+dw[u.dir]; 0<=nh&&nh<N && 0<=nw&&nw<M && field[nh][nw]!='#'; nh+=dh[u.dir], nw+=dw[u.dir]){
			if(nh == Sh && nw == Sw && u.dir == 1) break;
            
????????????????????????for(int i=-1; i<2; i++){
				if(nh == Sh && nw == Sw && i>=0) break;
                
????????????????????????????????State v({nh, nw, u.dir, u.pq});
????????????????????????????????if(i >= 0){
????????????????????????????????????????if(u.pq[i] == 0) continue;
????????????????????????????????????????v.pq[i]--;
????????????????????????????????????????v.dir = table[i][u.dir];
????????????????????????????????}
??????????????????????????????????
????????????????????????????????if(dist[v.h][v.w][v.dir][v.pq[0]][v.pq[1]] < 0){
????????????????????????????????????????dist[v.h][v.w][v.dir][v.pq[0]][v.pq[1]] = dist[u.h][u.w][u.dir][u.pq[0]][u.pq[1]];
????????????????????????????????????????if(i >= 0)
????????????????????????????????????????????????dist[v.h][v.w][v.dir][v.pq[0]][v.pq[1]]++;
????????????????????????????????????????if(v.h == Gh && v.w == Gw)
????????????????????????????????????????????????return dist[v.h][v.w][v.dir][v.pq[0]][v.pq[1]];
??????????????????????????????????????????
????????????????????????????????????????//cout << v.h << " " << v.w << " " << dist[v.h][v.w][v.dir][v.pq[0]][v.pq[1]] << endl;
????????????????????????????????????????que.push(v);
????????????????????????????????}
????????????????????????}
????????????????}
????????}
????????return -1;
}
??
int main(){
????????cin >> N >> M >> A;
????????field.resize(N);
????????for(auto &s: field) cin >> s;
??????????
????????for(int i=0; i<N; i++) for(int j=0; j<N; j++){
????????????????if(field[i][j] == 'S')
????????????????????????Sh = i, Sw = j;
????????????????if(field[i][j] == 'G')
????????????????????????Gh = i, Gw = j;
????????}
??????????
????????cout << bfs() << endl;
??????????
????????return 0;
}

Compiler output:
a.cc:24:7: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
   24 | ????????//map<State, int> dist;
a.cc:52:39: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
   52 | ????????????????????????????????????????//cout << v.h << " " << v.w << " " << dist[v.h][v.w][v.dir][v.pq[0]][v.pq[1]] << endl;
a.cc:3:1: error: expected unqualified-id before '?' token
    3 | ??
      | ^
a.cc:8:2: error: 'State' does not name a type; did you mean '_xstate'?
    8 | }State;
      |  ^~~~~
      |  _xstate
a.cc:9:1: error: expected unqualified-id before '?' token
    9 | ??
      | ^
a.cc:13:1: error: expected unqualified-id before '?' token
   13 | ??
      | ^
a.cc:17:1: error: expected unqualified-id before '?' token
   17 | ??
      | ^
a.cc:19:1: error: expected unqualified-id before '?' token
   19 | ??
      | ^
a.cc:21:1: error: expected unqualified-id before '?' token
   21 | ??
      | ^
a.cc:60:1: error: expected unqualified-id before '?' token
   60 | ??
      | ^