#ifndef INCLUDED_MAIN #define INCLUDED_MAIN #include __FILE__ int main(void){ ll h,w,m;cin>>h>>w>>m; vector g(h,vc(w)); pair s,goal; rep(i,h)rep(j,w){ cin>>g[i][j]; if(g[i][j]=='S') s={i,j}; if(g[i][j]=='G') goal={i,j}; } struct node{ int i; int j; int keyty; }; vector>> seen(h,vector>(w)); seen[s.first][s.second][0]=1; vector cur,nxt; cur.reserve(h*w);nxt.reserve(h*w); cur.push_back({s.first,s.second,0}); int depth=0; while(cur.size()){ for(auto &nd : cur){ if(nd.i==goal.first && nd.j==goal.second){ cout<='a'&&c<='i'){ int door=c-'a'+1; if(door!=kty)continue; } if(c>='1'&&c<='9')kty=c-'0'; if(!seen[ni][nj][kty]){ seen[ni][nj][kty]=1; nxt.push_back({ni,nj,kty}); } } } cur.clear(); swap(cur,nxt); depth++; } cout<<-1< using namespace std; #define rep(i,n) for(ll i=0;i=l;i--) using ll = long long; using ld = long double; const ll mod=998244353; #define nl "\n" #define vl vector #define vc vector #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() vector dx={-1,1,0,0},dy={0,0,-1,1}; bool isin(ll i,ll j,ll h,ll w){ return i>=0&&i=0&&j