水题,bfs一下即可。。。
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define mp(x, y) make_pair(x, y)
const int maxn = 105;
queue<pair<int, int> >q;
int vis[5][maxn];
char g[5][maxn];
int n, m;
bool check(int x, int y)
{
if(x <= 0 || x >= 4 || y <= 0 || y > n) return false;
if(g[x][y] != '.') return false;
return true;
}
void bfs()
{
for(int i = 1; i <= 3; i++)
for(int j = 1; j <= n; j++)
if(g[i][j] == 's') {
q.push(mp(i, j));
}
while(!q.empty()) {
int x = q.front().first, y = q.front().second;
q.pop();
if(vis[x][y] == 1) continue;
vis[x][y] = 1;
if(check(x, y+1)) {
vis[x][y+1] = 2;
if(check(x, y+2)) {
vis[x][y+2] = 2;
}
if(check(x-1, y+1)) {
vis[x-1][y+1] = 2;
if(check(x-1, y+2)) vis[x-1][y+2] = 2;
}
if(check(x+1, y+1)) {
vis[x+1][y+1] = 2;
if(check(x+1, y+2)) vis[x+1][y+2] = 2;
}
}
if(check(x, y+1) && check(x-1, y+1) && check(x-1, y+2) && check(x-1, y+3)) q.push(mp(x-1, y+3));
if(check(x, y+1) && check(x, y+2) && check(x, y+3)) q.push(mp(x, y+3));
if(check(x, y+1) && check(x+1, y+1) && check(x+1, y+2) && check(x+1, y+3)) q.push(mp(x+1, y+3));
}
}
void debug()
{
for(int i = 1; i <= 3; i++) {
for(int j = 1; j <= n; j++) {
printf("%d ", vis[i][j]);
}
printf("\n");
}
}
void work()
{
scanf("%d%d", &n, &m);
memset(vis, 0, sizeof vis);
for(int i = 1; i <= 3; i++) {
scanf("%s", g[i]+1);
}
bfs();
for(int i = 1; i <= 3; i++) if(vis[i][n]) {
printf("YES\n");
return;
}
printf("NO\n");
}
int main()
{
//freopen("data", "r", stdin);
int _;
scanf("%d", &_);
while(_--) work();
return 0;
}