#include using namespace std; vector > vec, aux; vector,pair > > tuneles; vector maze; void alCuadrado() { aux = vec; int n = vec.size(); for(int i=0;i getDest(pair p) { for(int i=0;i> n >> m >> k; int init = -1; vec.resize(n*m,vector(n*m,0.)); maze.resize(n); for(int a0 = 0; a0 < n; a0++){ cin >> maze[a0]; for(int j=0;j> i1 >> j1 >> i2 >> j2; tuneles.push_back(make_pair(make_pair(i1-1,j1-1),make_pair(i2-1,j2-1))); } for(int i=0;i > neighbours; if(i-1 >= 0 && maze[i-1][j] != '#') { neighbours.push_back(make_pair(i-1,j)); } if(i+1 < n && maze[i+1][j] != '#') { neighbours.push_back(make_pair(i+1,j)); } if(j-1 >= 0 && maze[i][j-1] != '#') { neighbours.push_back(make_pair(i,j-1)); } if(j+1 < m && maze[i][j+1] != '#') { neighbours.push_back(make_pair(i,j+1)); } long double p = 1./(long double)(neighbours.size()); for(int ii=0;ii dest = getDest(neighbours[ii]); int d = dest.first*m+dest.second; vec[i*m+j][d] = p; } } else if(maze[i][j] == '*') { vec[i*m+j][i*m+j] = 1.; } } } for(int i=0;i<20;i++) { alCuadrado(); } long double res = 0; for(int i=0;i