Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cstdio>
    
#define f first
#define s second
    
using namespace std;
    
typedef pair<int,int> P;
    
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
    
int main(void){
    
int n,id=0;
string s="ABCDEFGHI";
char s,t,d;
map<char,P>mp;
    
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
mp[s[id++]]=P(j,i);
}
}
    
while(cin >> n,n){
cin >> s >> t >> d;
 
P S,T,D;
S.f=mp[s].f,S.s=mp[s].s;
T.f=mp[t].f,T.s=mp[t].s;
D.f=mp[d].f,D.s=mp[d].s;
 
double dp[16][3][3];
    
for(int k=0;k<16;k++)
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)dp[k][i][j]=0;
    
dp[0][S.s][S.f]=1;
    
for(int k=0;k<n;k++){
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
for(int l=0;l<4;l++){
int nx=j+dx[l],ny=i+dy[l];
if(nx<0 || ny<0 || 2<nx || 2<ny || 
(nx==D.s&&ny==D.f))nx=j,ny=i;
dp[k+1][ny][nx]+=dp[k][i][j]/4;
}
}
}
}
printf("%.8f",dp[n][T.s][T.f]);
cout << endl;
}
    
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:11: error: conflicting declaration 'char second'
    9 | #define s second
      |           ^~~~~~
a.cc:22:6: note: in expansion of macro 's'
   22 | char s,t,d;
      |      ^
a.cc:9:11: note: previous declaration as 'std::string second'
    9 | #define s second
      |           ^~~~~~
a.cc:21:8: note: in expansion of macro 's'
   21 | string s="ABCDEFGHI";
      |        ^
a.cc:35:7: error: no match for 'operator[]' (operand types are 'std::map<char, std::pair<int, int> >' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   35 | S.f=mp[s].f,S.s=mp[s].s;
      |       ^
In file included from /usr/include/c++/14/map:63,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::map<char, std::pair<int, int> >::key_type&' {aka 'const char&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<char, std::pair<int, int> >::key_type&&' {aka 'char&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
a.cc:35:19: error: no match for 'operator[]' (operand types are 'std::map<char, std::pair<int, int> >' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   35 | S.f=mp[s].f,S.s=mp[s].s;
      |                   ^
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::map<char, std::pair<int, int> >::key_type&' {aka 'const char&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<char, std::pair<int, int> >::key_type&&' {aka 'char&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~