#include #define vs vector #define vpii vector > #define vi vector #define vvi vector #define pb push_back using namespace std; void myfunc(vs& vst, vpii& vtp1, vpii& vtp2, double* ans); pair getinitial(vs& vst); int main() { int n,m,k; vs vst; cin >> n >> m >> k; for(int a0 = 0; a0 < n; a0++){ string row; cin >> row; vst.pb(row); // Write Your Code Here } vpii vtp1,vtp2; for(int a0 = 0; a0 < k; a0++){ int i1,j1,i2,j2; cin >> i1 >> j1 >> i2 >> j2; vtp1.pb(make_pair(i1-1,j1-1)); vtp2.pb(make_pair(i2-1,j2-1)); // Write Your Code Here } // Write Your Code Here double ans = 0; myfunc(vst,vtp1,vtp2,&ans); cout << ans << endl; return 0; } pair getinitial(vs& vst) { for(int i=0;i init_pos = getinitial(vst); list > lt; lt.pb(init_pos); lt.pb(make_pair(-1,-1)); int level = 1; while(!lt.empty()) { pair x = lt.front(); lt.pop_front(); int xth = x.first; int yth = x.second; if(xth==-1 && yth==-1) { level++; if(!lt.empty()) lt.pb(make_pair(-1,-1)); } else { visited[xth][yth] = 1; if(vst[xth][yth]=='%') { *ans = *ans + pow(0.25,level); } else { if(xth-1>=0 && (vst[xth-1][yth]=='0'|| vst[xth-1][yth]=='%') && visited[xth-1][yth]==0) lt.pb(make_pair(xth-1,yth)); if(xth+1=0 && (vst[xth-1][yth]=='0'|| vst[xth-1][yth]=='%') && visited[xth][yth-1]==0) lt.pb(make_pair(xth,yth-1)); if(yth+1