AcWing 3228. 俄罗斯方块
原题链接
简单
作者:
Value
,
2021-04-10 13:59:23
,
所有人可见
,
阅读 673
#include <iostream>
using namespace std;
const int N = 30;
int graph[N][N];
int t[4][4];
bool check(int row, int col){
for(int i = 0; i < 4; i ++ ){
for(int j = 0; j < 4; j ++ ){
if(i + row >= 15 && t[i][j] == 1) return true;
if(graph[i + row][j + col] && t[i][j]) return true;
}
}
return false;
}
int main(){
for(int i = 0; i < 15; i ++ )
for(int j = 0; j < 10; j ++ )
cin >> graph[i][j];
for(int i = 0; i < 4; i ++ )
for(int j = 0; j < 4; j ++ )
cin >> t[i][j];
int col; cin >> col;
col -- ;
int k = 1;
while(k < 15){
if(check(k, col)) break;
k ++ ;
}
k -- ;
for(int i = k; i < k + 4; i ++ ){
for(int j = col; j < col + 4; j ++ )
graph[i][j] = t[i - k][j - col] == 0 ? graph[i][j] : 1;
}
for(int i = 0; i < 15; i ++ ){
for(int j = 0; j < 10; j ++ ){
cout << graph[i][j] << ' ';
}
cout << endl;
}
return 0;
}