一、问题链接
CSP 201604-2 俄罗斯方块
二、参考代码
#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
vector<vector<int>> a(20,vector<int>(15));
int col;
for(int i=0; i<15; i++) {
for(int j=0; j<10; j++) {
cin>>a[i][j];
}
}
vector<pair<int,int>> xy;
int temp;
for(int i=0; i<4; i++) {
for(int j=0; j<4; j++) {
cin>>temp;
if(temp==1) {
xy.push_back({i,j});
}
}
}
cin>>col;
col--;
for(auto &i : xy) {
i.second+=col;
}
while(1) {
for(auto &i : xy) {
if(a[i.first+1][i.second]==1 or i.first==14) {
goto loop;
}
}
for(auto &i : xy) {
i.first++;
}
}
loop:;
for(auto &i : xy) {
a[i.first][i.second]=1;
}
for(int i=0; i<15; i++) {
for(int j=0; j<10; j++) {
cout<<a[i][j]<<" ";
}
cout<<"\n";
}
return 0;
}