AcWing 3223. 消除类游戏
原题链接
简单
作者:
Value
,
2021-04-04 09:29:34
,
所有人可见
,
阅读 286
#include <iostream>
using namespace std;
const int N = 100;
int a[N][N];
bool flag[N][N];
int n, m;
int main(){
cin >> n >> m;
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++ ) cin >> a[i][j];
}
for(int i = 0; i < n; i ++ )
for(int j = 0; j < m; j ++ )
if(j + 2 < m && a[i][j] == a[i][j + 1] && a[i][j] == a[i][j + 2])
flag[i][j] = flag[i][j + 1] = flag[i][j + 2] = true;
for(int j = 0; j < m; j ++ )
for(int i = 0; i < n; i ++ )
if(i + 2 < n && a[i][j] == a[i + 1][j] && a[i][j] == a[i + 2][j])
flag[i][j] = flag[i + 1][j] = flag[i + 2][j] = true;
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++){
if(flag[i][j]) cout << 0;
else cout << a[i][j];
cout << ' ' ;
}
cout << endl;
}
return 0;
}