CCF 201604-2 Tetris (analog)

Source: Internet
Author: User
Tags cmath

Problem DescriptionTetris is a casual game invented by Russian Alexei Pakitenov.
The game is performed on a grid of 15 rows and 10 columns, and each lattice on the grid may have been placed on a block or not placed. Each round, there will be a new plate composed of 4 small blocks from the top of the chart, the player can operate the plate left and right to the appropriate position, when the lower edge of a block in the plate and the square on the upper edge of the block is coincident or reached the lower boundary, the plate no longer move, If a row of the grid is full of squares at this point, the row is eliminated and scored.
In this case, you need to write a program to simulate the whereabouts of the plate, you do not have to deal with the player's actions, and do not need to deal with the elimination and scoring.
Specifically, given an initial grid chart, as well as the shape of a plate and the initial position of its whereabouts, you have to give the final square chart. Input FormatThe first 15 lines of input contain the initial square chart, each row contains 10 digits, and the adjacent numbers are separated by a space. If a number is 0, it means that there is no block in the corresponding square, and if the number is 1, it is the initial block. The input guarantees that the number in the first 4 rows is 0.
The 16th to 19th line of input contains the shape of the newly added plate, each row contains 4 numbers, the plate pattern is formed, the same 0 means no squares, and 1 represents a block. The input guarantees that the pattern of the plate contains exactly 4 blocks, and 4 blocks are connected (to be exact, 4 blocks are four connected, that is, the given plate is the standard plate of the Tetris).
The 20th line contains an integer from 1 to 7, which indicates which column of the block pattern is in the left-most part of the chart. Note that the plate pattern here refers to the plate pattern entered by rows 16 to 19, if the leftmost column of the plate pattern is all 0, then its left side is inconsistent with the left side of the plate actually represented (see example) output FormatOutput 15 lines, 10 digits per line, separated by a space between adjacent numbers, indicating a square chart behind the plate. Note that you do not have to deal with the final elimination of the line. Sample Input0 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 Sample Output0 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 Analysis: The problem is to simulate its whereabouts, if the whereabouts of the cover 1, or down to the bottom, then the end. The code is as follows:
#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include <cstdio> #include <string> #include < cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include < queue> #include <algorithm> #include <vector> #include <map> #include <cctype> #include < cmath> #include <stack> #define FREOPENR freopen ("In.txt", "R", stdin) #define FREOPENW freopen ("OUT.txt", "W",  STDOUT) using namespace Std;typedef long Long ll;typedef pair<int, int> p;const int inf = 0x3f3f3f3f;const double inf = 0x3f3f3f3f3f3f;const Double PI = ACOs ( -1.0); const double EPS = 1e-8;const int maxn = 1e3 + 5;const int mod = 1e9 + 7;co NST char *mark = "+-*"; const int dr[] = {-1, 0, 1, 0};const int dc[] = {0, 1, 0, -1};const char *de[] = {"0000", "0001", " 0010 "," 0011 "," 0100 "," 0101 "," 0110 "," 0111 "," N "," 1001 "," 1010 "," 1011 "," 1100 "," 1101 "," 1110 "," 1111 "};int N, M;co NST int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, +, 31};const int monn[] = {0, h, H, a, A, a,, a, a, a, a,, 31};inline int Min (int a, int b) {Retu RN a < b? A:B; }inline int Max (int a, int b) {return a > b a:b;} inline ll Min (ll A, ll b) {return a < b a:b;} inline ll Max (ll A, ll b) {return a > b a:b;} inline bool Is_in (int r, int c) {return R >= 0 && r < n && C >= 0 && C < m;}            int A[20][15];int B[10][10];int Main () {for (int i = 1; I <=, ++i) for (int j = 1; J <=; ++j)    scanf ("%d", &a[i][j]);    for (int i = 1; i < 5; ++i) for (int j = 1; j < 5; ++j) scanf ("%d", &b[i][j]);    scanf ("%d", &n);    int cnt = 5;        while (true) {bool OK = false; for (int i = cnt; i > cnt-4;-i) {for (int j = n; j < n+4; ++j) if ((A[i][j] && b[i- CNT+4][J-N+1]) | | (I >= && b[i-cnt+4][j-n+1]))            {ok = true; break;}   if (OK) break;     } if (OK) break;    ++cnt;    }--cnt;    for (int i = cnt; i > cnt-4;-i) for (int j = n; j < n+4; ++j) a[i][j] |= b[i-cnt+4][j-n+1];            for (int i = 1; i < n; ++i) for (int j = 1; j < one; ++j) if (ten = = j) printf ("%d\n", A[i][j]);    else printf ("%d", a[i][j]); return 0;}

CCF 201604-2 Tetris (analog)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.