#include using namespace std; #define int long long #define double long double #define f first #define s second string s1[54],s2[54]; int r,c,dist[54][54]; bool vis[54][54]; vector,pair>> moves; bool neigh (int x, int y) { if (x>0 && s1[x-1][y]=='*') return true; if (y>0 && s1[x][y-1]=='*') return true; if (x>r>>c; for (int i=0;i>s1[i]; for (int i=0;i>s2[i]; for (int i=0;i> q; q.push({i,j}); dist[i][j]=0; while (!q.empty()) { int x = q.front().first; int y = q.front().second; q.pop(); int new_d=dist[x][y]+1; if (y<(c-1) && s1[x][y+1]!='X') { if (dist[x][y+1] > new_d) { dist[x][y+1]=new_d; q.push({x,y+1}); } } if (x<(r-1) && s1[x+1][y]!='X') { if (dist[x+1][y] > new_d) { dist[x+1][y]=new_d; q.push({x+1,y}); } } if (y>0 && s1[x][y-1]!='X') { if (dist[x][y-1] > new_d) { dist[x][y-1]=new_d; q.push({x,y-1}); } } if (x>0 && s1[x-1][y]!='X') { if (dist[x - 1][y] > new_d) { dist[x - 1][y] = new_d; q.push({x - 1, y}); } } } } } bool ok=true; int total_dist = 0; for (int i=0;i10000) ok=false; total_dist += dist[i][j]; } } if (!ok) { cout<<"NO"; return; } int nr=0; while (nr<=10000 && total_dist>0) { int pos1x=0; int pos1y=0; int pos2x=0; int pos2y=0; int prev_dist = total_dist; int max_dist=0; int min_dist=10001; for (int i=0;imax_dist) { max_dist=dist[i][j]; pos1x=i; pos1y=j; } } for (int i=0;i=0); if (total_dist==0) { cout<<"YES"<<'\n'; cout<> t; while (t--) { find(); } return 0; }