#include #include #include #include #include using namespace std; int n,m,k; int maze[22][22]={0}; int tun[21][21]={0}; pair tunnel[21][21]; bool flag=false; float pro=0.00; void move(int x,int y,float ans,int row,int col,int visited[21][21]){ if(x<1 ||y<1 || x>col ||y>row){ return; } if(maze[y][x]==int('#')){ return; } if(visited[y][x]==1 || maze[y][x]==int('*')){ return; } visited[x][y]=1; if(tun[y][x]==1){ int a=tunnel[y][x].first; int b=tunnel[y][x].second; visited[y][x]=1; move(a,b,ans,row,col,visited); visited[y][x]=0; if(flag==true){ return; } return; } visited[y][x]=1; if(maze[y][x]==int('%')){ pro=ans; flag=true; return; } int pos=0; if(y-1>0 && maze[y-1][x]!=int('#')){ pos++; } if(y+1<=row && maze[y+1][x]!=int('#')){ pos++; } if(x-1>0 && maze[y][x-1]!=int('#')){ pos++; } if(x+1<=col && maze[y][x-1]!=int('#')){ pos++; } //cout<>n>>m>>k; string s; int x=0,y=0; for(int i=1;i<=n;i++){ cin>>s; for(int j=0;j>x1>>y1>>x2>>y2; tun[x1][y1]=1; tun[x2][y2]=1; tunnel[x1][y1]=make_pair(x2,y2); tunnel[x2][y2]=make_pair(x1,y1); } int visited[21][21]={0}; move(x,y,1.00,n,m,visited); cout<