• csp-俄罗斯方块


    always的90

    想不出来那10分是哪。有大佬知道的话辛苦告诉小弟一下,感激!

    问题描述

    试题编号: 201604-2
    试题名称: 俄罗斯方块
    时间限制: 1.0s
    内存限制: 256.0MB
    问题描述:
    问题描述
      俄罗斯方块是俄罗斯人阿列克谢·帕基特诺夫发明的一款休闲游戏。
      游戏在一个15行10列的方格图上进行,方格图上的每一个格子可能已经放置了方块,或者没有放置方块。每一轮,都会有一个新的由4个小方块组成的板块从方格图的上方落下,玩家可以操作板块左右移动放到合适的位置,当板块中某一个方块的下边缘与方格图上的方块上边缘重合或者达到下边界时,板块不再移动,如果此时方格图的某一行全放满了方块,则该行被消除并得分。
      在这个问题中,你需要写一个程序来模拟板块下落,你不需要处理玩家的操作,也不需要处理消行和得分。
      具体的,给定一个初始的方格图,以及一个板块的形状和它下落的初始位置,你要给出最终的方格图。
    输入格式
      输入的前15行包含初始的方格图,每行包含10个数字,相邻的数字用空格分隔。如果一个数字是0,表示对应的方格中没有方块,如果数字是1,则表示初始的时候有方块。输入保证前4行中的数字都是0。
      输入的第16至第19行包含新加入的板块的形状,每行包含4个数字,组成了板块图案,同样0表示没方块,1表示有方块。输入保证板块的图案中正好包含4个方块,且4个方块是连在一起的(准确的说,4个方块是四连通的,即给定的板块是俄罗斯方块的标准板块)。
      第20行包含一个1到7之间的整数,表示板块图案最左边开始的时候是在方格图的哪一列中。注意,这里的板块图案指的是16至19行所输入的板块图案,如果板块图案的最左边一列全是0,则它的左边和实际所表示的板块的左边是不一致的(见样例)
    输出格式
      输出15行,每行10个数字,相邻的数字之间用一个空格分隔,表示板块下落后的方格图。注意,你不需要处理最终的消行。
    样例输入
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 1 0 0
    0 0 0 0 0 0 1 0 0 0
    0 0 0 0 0 0 1 0 0 0
    1 1 1 0 0 0 1 1 1 1
    0 0 0 0 1 0 0 0 0 0
    0 0 0 0
    0 1 1 1
    0 0 0 1
    0 0 0 0
    3
    样例输出
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 1 0 0
    0 0 0 0 0 0 1 0 0 0
    0 0 0 0 0 0 1 0 0 0
    1 1 1 1 1 1 1 1 1 1
    0 0 0 0 1 1 0 0 0 0

     思路是模拟下降过程。

    代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 int m[16][10];
     4 
     5 int main()
     6 {
     7     int t,x;
     8     int p[4],l[4];
     9     int s[4][4];
    10     for(int i = 0 ; i < 15;i++){
    11         for(int j = 0 ; j < 10;j++){
    12             cin >> m[i][j];
    13         }
    14     }
    15     for(int i = 0 ; i < 10;i++){
    16         m[15][i] = 1;
    17     }
    18 
    19     for(int i = 0;i < 4;i++){
    20         for(int j = 0 ; j < 4;j++){
    21             cin >> s[i][j];
    22         }
    23     }
    24     cin >> t;
    25     ///放入板块
    26     for(int i = 0 ; i < 4;i++){
    27         p[i] = l[i] = 0;
    28         for(int j = t - 1,x = 0; j < t + 3;j++,x++){
    29             m[i][j] = s[i][x];
    30         }
    31     }
    32     //找到最底层的1
    33     for(int i = 0 ; i < 4;i++){
    34         for(int j = 0 ; j < 4;j++){
    35             if(s[j][i]){
    36                 p[i] = j;
    37                 l[i] = p[i];
    38             }
    39         }
    40     }
    41     ///下行
    42     int q = 3;///最底层
    43     int flag = 0;
    44     while(!flag){
    45         if(m[p[0] + 1][t - 1] || m[p[1] + 1][t] || m[p[2] + 1][t + 1] || m[p[3]+1][t + 2] ){
    46             flag = 1;
    47         }else{
    48  //           cout << l[0] << endl;
    49             ///下行一格
    50             for(int i = 0 ; i <= l[0];i++){
    51                 m[p[0]-i+1][t-1] = m[p[0] - i][t-1];
    52             }
    53             for(int i = 0 ; i <= l[1];i++){
    54                 m[p[1]-i+1][t] = m[p[1] - i][t];
    55             }
    56             for(int i = 0 ; i <= l[2];i++){
    57                 m[p[2]-i+1][t+1] = m[p[2] - i][t+1];
    58             }
    59             for(int i = 0 ; i <= l[3];i++){
    60                 m[p[3]-i+1][t+2] = m[p[3] - i][t+2];
    61             }
    62 //            cout << "qqq" << endl;
    63 
    64             m[p[0]-l[0]][t - 1] = 0;
    65             m[p[1]-l[1]][t] = 0;
    66             m[p[2]-l[2]][t + 1] = 0;
    67             m[p[3]-l[3]][t + 2] = 0;
    68             for(int i = 0 ; i < 4;i++){
    69                 p[i]++;
    70             }
    71            // q++;
    72             ///调试打印
    73            /* cout << "print-------" << q - 3 << endl;
    74             for(int i = 0 ; i < 15;i++){
    75                 for(int j = 0 ; j < 10;j++){
    76                     cout << m[i][j] << " ";
    77                 }
    78                 cout << endl;1
    79             }
    80             */
    81         }
    82     }
    83     for(int i = 0 ; i < 15;i++){
    84         for(int j = 0 ; j < 10;j++){
    85             cout << m[i][j] << " ";
    86         }
    87         cout << endl;
    88     }
    89     return 0;
    90 }
  • 相关阅读:
    判断用户是否登录
    django 请求中的认证
    django 验证密码
    CXF+Spring搭建webservice服务
    CXF+Spring搭建webservice服务
    CXF+Spring搭建webservice服务
    关于本地用svn up的时候报cannot update svn folder: "unversioned directory of the same name already exists...
    关于本地用svn up的时候报cannot update svn folder: "unversioned directory of the same name already exists...
    关于本地用svn up的时候报cannot update svn folder: "unversioned directory of the same name already exists...
    关于本地用svn up的时候报cannot update svn folder: "unversioned directory of the same name already exists...
  • 原文地址:https://www.cnblogs.com/gudygudy/p/9577505.html
Copyright © 2020-2023  润新知