#include <cstdio> #include <iostream> #include <cstring> #include <string> #include <algorithm> using namespace std; const int maxn = 100 + 10; int dir[][2] = { {0,1},{1,1} ,{1,0},{1,-1},{0,-1},{-1,-1} ,{-1,0} ,{-1,1} }; char fz[maxn][maxn]; int vis[maxn][maxn]; char stand[] = "yizhong"; struct node { int x, y; }c[maxn]; void dfs(int x,int y,int k,int cur) { if (cur == 7) for (int i = 0; i < 7; i++) vis[c[i].x][c[i].y] = 1; else { int dx = x + dir[k][0]; int dy = y + dir[k][1]; if (cur == 6 || fz[dx][dy] == stand[cur + 1]) { c[cur].x = x; c[cur].y = y; dfs(dx, dy, k, cur + 1); }
}
}
int main() { int n; cin >> n; memset(vis, 0, sizeof(vis)); for (int i = 0; i < n; i++) cin >> fz[i]; for(int i = 0;i < n;i++) for(int j = 0;j < n;j++) if(fz[i][j] == 'y') for (int k = 0; k < 8; k++) { int dx = i + dir[k][0]; int dy = j + dir[k][1]; if (fz[dx][dy] == 'i') dfs(i, j, k, 0); }
for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (!vis[i][j]) cout << "*"; else cout << fz[i][j]; cout << endl; } }
|