A1100 | [COCI-2006_2007-regional]#4 TETRIS
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Tetris is a popular computer game played in a field consisting of C columns and an unlimited number of rows. In one move, one of the following seven pieces is dropped into the field:
When dropping the piece, the player is free to rotate the piece 90, 180 or 270 degrees and to move it left or right, as long as the piece stays entirely in the field. The piece then falls until it settles on the bottom of the field or on already occupied squares. In our variant of Tetris the piece must fall so that all parts of the piece are on the bottom of the field or on already occupied squares. In other words, after the piece falls there may not be a free square such that some square above it is occupied.
For example, let the field be six columns wide with initial heights (the number of already occupied squares in each column) 2, 1, 1, 1, 0 and
1. Piece number 5 can then be dropped into the field in five different ways:
You are given the initial heights of all columns and the figure to be dropped into the field.
Write a program that calculates the number of different ways to do this, i.e. the number of different field configurations that can be achieved by dropping the piece.
When dropping the piece, the player is free to rotate the piece 90, 180 or 270 degrees and to move it left or right, as long as the piece stays entirely in the field. The piece then falls until it settles on the bottom of the field or on already occupied squares. In our variant of Tetris the piece must fall so that all parts of the piece are on the bottom of the field or on already occupied squares. In other words, after the piece falls there may not be a free square such that some square above it is occupied.
For example, let the field be six columns wide with initial heights (the number of already occupied squares in each column) 2, 1, 1, 1, 0 and
1. Piece number 5 can then be dropped into the field in five different ways:
You are given the initial heights of all columns and the figure to be dropped into the field.
Write a program that calculates the number of different ways to do this, i.e. the number of different field configurations that can be achieved by dropping the piece.
输入格式
The first line contains two integers C and P, 1 ≤ C ≤ 100, 1 ≤ P ≤ 7, the number of columns and the number of the piece to be dropped.
The second line contains C integers separated by single spaces, each between 0 and 100, inclusive.
These are the initial heights of the columns.
The second line contains C integers separated by single spaces, each between 0 and 100, inclusive.
These are the initial heights of the columns.
输出格式
Output on a single line the number of different ways to drop the piece in the field.
输入输出样例
输入 #1
6 5 2 1 1 1 0 1
输出 #1
5
输入 #2
5 1 0 0 0 0 0
输出 #2
7
输入 #3
9 4 4 3 5 4 6 5 7 6 6
输出 #3
1
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted