#include<bits/stdc++.h>
using namespace std;
const string s="yizhong";
int n;
int dx[]={1,1,1,0,0,-1,-1,-1};
int dy[]={1,-1,0,1,-1,1,-1,0};
char a[101][101];
bool ans[101][101];
bool dfs(int x,int y,int tx,int ty,int d){
if(x<1||x>n||y<1||y>n)return 0;
if(d>=6){
ans[x][y]=1;
return 1;
}
if(a[x][y]==s[d]){
if(dfs(x+tx,y+ty,tx,ty,d+1)){
ans[x][y]=1;
return 1;
}
return 0;
}
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++)cin>>a[i][j];
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(a[i][j]=='y'){
for(int c=0;c<8;c++){
dfs(i,j,dx[c],dy[c],0);
}
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(ans[i][j])cout<<a[i][j];
else cout<<"*";
}
cout<<endl;
}
}
测试点1(样例#2)我的输出:
*yizhong
gy******
n*i*****
o**z****
h***h***
z****o**
i*****n*
y******g
测试点1(样例#2)标准输出:
*yizhong
gy******
n*i*****
o**z****
h***h***
z****o**
i*****n*
y******g
什么鬼