1 条题解
-
0
C++ :
// luogu-judger-enable-o2 #include<bits/stdc++.h> using namespace std; int n,a[31][31],f[31][31]; void dfs(int i,int j){ if(i<0||i>n+1||j<0||j>n+1||f[i][j]==1) return; f[i][j] = 1; dfs(i,j+1); dfs(i+1,j); dfs(i,j-1); dfs(i-1,j); } int main(){ int i,j; cin>>n; for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ cin>>f[i][j]; a[i][j] = f[i][j]; } } dfs(0,0); for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ if(f[i][j]==0) cout<<2<<" "; else cout<<a[i][j]<<" "; } cout<<endl; } return 0; }
- 1
信息
- ID
- 2690
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者