#include <iostream>
#include <string.h>
using namespace std;
const int row = 15, col = 10;
const int size = 4;
int road[row+size][col];
int block[size][size];
int startcol;
bool iscollision(int ix){
int x = size-1;
int y = 0;
for (int i = ix; i >=0 && i>=ix-size+1 ; --i) {
for (int j = startcol; j <startcol+size ; ++j) {
if (block[x][y]&&road[i][j]||block[x][y]&&i==row){
return true;
}
y++;
}
x--;
y = 0;
}
return false;
}
void update(int ix){
int x = size-1;
int y = 0;
for (int i = ix; i >=0 && i>=ix-size+1 ; --i) {
for (int j = startcol; j <startcol+size ; ++j) {
if (block[x][y]){
road[i][j] = block[x][y];
}
y++;
}
x--;
y = 0;
}
}
int main(){
// first, init the road
memset(road, 0, sizeof(road));
for (int i = 0; i < row; ++i) {
for (int j = 0; j < col; ++j) {
cin>>road[i][j];
}
}
// init the falling block
for (int i = 0; i < size; ++i) {
for (int j = 0; j < size; ++j) {
cin>>block[i][j];
}
}
cin>>startcol;
startcol -= 1;
// calculate the last row
for (int i = 0; i < row+size; ++i) {
if (iscollision(i)){
// backward, update the road on row= i -1;
update(i-1);
break;
}
}
// cout the result
for (int i = 0; i < row; ++i) {
cout<<road[i][0];
for (int j = 1; j < col; ++j) {
cout<<" "<<road[i][j];
}
cout<<endl;
}
}
ccf csp 俄罗斯方块
最新推荐文章于 2023-02-20 22:12:02 发布