1 solutions
-
0
#include<bits/stdc++.h> using namespace std; const int N=110; char g[N][N],bg[N][N],bbg[N][N]; int dx[]={-1,-1,-1,0,0,1,1,1}; int dy[]={-1,0,1,-1,1,-1,0,1}; int main() { int n,m; cin>>n>>m; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cin>>g[i][j]; } } int x,y; cin>>x>>y; if(g[x][y]!='0') { bg[x][y]='2'; while(1) { int cnt=0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(g[i][j]=='1'&&bg[i][j]=='2'&&bbg[i][j]==0) { bbg[i][j]=1; cnt++; for(int k=0;k<8;k++) { int a=i+dx[k],b=j+dy[k]; bg[a][b]='2'; } } } } // cout<<cnt<<endl; if(cnt==0) break; } } for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cout<<max(g[i][j],bg[i][j]); } cout<<endl; } return 0; }
- 1
Information
- ID
- 2876
- Time
- 1000ms
- Memory
- 64MiB
- Difficulty
- 10
- Tags
- # Submissions
- 8
- Accepted
- 2
- Uploaded By