2016年CCF第七次测试 俄罗斯方块

 1 //2016年CCF第七次测试 俄罗斯方块
 2 // 这道小模拟题还是不错
 3 // 思路:处理出输入矩阵中含1格子的行数和列数
 4 // 再判是否有一个格子碰到底部,否则整体再往下移动一步,如果有一个格子不能移动,要返回到前一步
 5 
 6 #include <bits/stdc++.h>
 7 using namespace std;
 8 #define LL long long
 9 const double inf = 123456789012345.0;
10 const LL MOD =100000000LL;
11 const int N =1e7+10;
12 #define clc(a,b) memset(a,b,sizeof(a))
13 const double eps = 1e-7;
14 void fre() {freopen("in.txt","r",stdin);}
15 void freout() {freopen("out.txt","w",stdout);}
16 inline int read() {int x=0,f=1;char ch=getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch=getchar();}while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}return x*f;}
17 
18 int g[15][15],p[5][5];
19 int x[5],y[5];
20 int main(){
21     // fre();
22     for(int i=0;i<15;i++){
23         for(int j=0;j<10;j++){
24             scanf("%d",&g[i][j]);
25         }
26     }
27     int b;
28     for(int i=0;i<4;i++){
29         for(int j=0;j<4;j++){
30             scanf("%d",&p[i][j]);
31         }
32     }
33     int k=0;
34     scanf("%d",&b);
35     for(int i=0;i<4;i++){
36         for(int j=0;j<4;j++){
37             if(p[i][j]==1){
38                 x[k]=i;
39                 y[k++]=j+b-1;
40             }
41         }
42     }
43     int step=0;
44     int count=0;
45     bool flag=true,flag2=true;
46     while(flag){
47         for(int i=0;i<4;i++){
48             if(x[i]+step==14){
49                 for(int j=0;j<4;j++){
50                     g[x[j]+step][y[j]]=1;
51                 }
52                 flag2=false;
53                 break;
54             }
55             if(g[x[i]+step][y[i]]==0){
56                 count++;
57             }
58         }
59         if(flag2==false) break;
60         if(count==4){
61             step++;
62             count=0;
63         }
64         else{
65             for(int i=0;i<4;i++){
66                 g[x[i]+step-1][y[i]]=1;
67             }
68             flag=false;
69         }
70     }
71     for(int i=0;i<15;i++){
72         for(int j=0;j<10;j++){
73             printf("%d ",g[i][j]);
74         }
75         printf("
");
76     }
77     return 0;
78 }
原文地址:https://www.cnblogs.com/ITUPC/p/5847481.html