#P4420. [COCI2017-2018#1] Tetris
[COCI2017-2018#1] Tetris
题目描述
Ivica is a passionate computer scientist. He recently started working on his first computer game: a clone of the popular Tetris. Although he’s far from being finished, his program supports placing five different Tetris figures shown in the image below in a matrix. Before placing it in the Tetris matrix, the figure can be rotated by 90 degrees an arbitrary number of times and coloured. Additionally, the current version of the game doesn’t support placing the figure if that would mean it goes out of the matrix boundaries or overlaps with another existing figure in the matrix.
While Ivica was in school, his sister Marica started the game and randomly rotated, coloured and placed the figures in a way that the adjacent figures are coloured differently. Two figures are adjacent if they share a common side or touch in the tip.
When Ivica came back to his computer, he found the game running with the figures his sister placed. He wants to know how many of which figures there are in the Tetris matrix and he is asking you to help him solve this problem while he’s busy with improving the game.
输入格式
The first line of input contains positive integers N and M (1 ≤ N, M ≤ 10) that represent the number of rows and columns of the Tetris matrix.
Each of the following N lines contains M characters that represent the matrix. Each character can be ‘.’ (dot) that represents a blank space or a lowercase letter of the English alphabet that represents a part of the figure. Different letters represent different colours, and the parts of the same figure are coloured the same.
输出格式
You must output exactly five rows. The line must contain the number of appearances of the figure in the game of Tetris.
题目大意
题目描述
Ivica是一位激情昂扬的计算机科学家。他最近开始研究他的第一个电脑游戏:流行于当下的俄罗斯方块的克隆。尽管他还远未完成,但他的研究计划却支持将下图中显示的五种不同的俄罗斯方块图形放在一个矩阵中。在将它放入俄罗斯方块矩阵之前,图形可以旋转90度任意次数并着色。此外,当前版本的游戏不支持放置俄罗斯方块图形,如果这意味着它将超出矩阵边界或与矩阵中的另一个现有图形重叠。
当Ivica在学校时,他的妹妹Marica开始游戏并随机旋转,着色并放置俄罗斯方块图形,使相邻的那一些俄罗斯方块颜色不同。如果它们在共用一个共同的侧面或两两相触,则两个图形相邻。(PS:【译者注】当然,一个点{角}不算)
当Ivica回到他的电脑后,他发现游戏正在运行着他妹妹放置的俄罗斯方块图形。他想知道俄罗斯方块矩阵中有多少数字,他要求你在他忙于改进游戏时帮助他解决这个问题。
输入输出格式
输入格式:
第一行输入包含正整数N和M(1≤N,M≤10),表示俄罗斯方块矩阵的行数和列数。
以下N行中的每一行包含表示矩阵的M个字符。每个角色都可以是'.' (点)表示空格或英文字母的小写字母,代表图的一部分。不同的字母代表不同的颜色,同一图的部分颜色相同。
输出格式:
你必须输出五行。第 行需要包含 图中方块的游戏的出现次数。
说明
20%的测试样例中,只有一个数字。
在测试案例中,总价值额外增加20%(也就是40%),只会出现两个数字。
在测试案例中,总价值额外增加20%(当然,也就是60%),出现三个数字。
在测试案例中,总价值额外增加20%,(嗯嗯就是80%),会出现前四个数字
翻译贡献者UID:118559
4 5
aaaa.
.bb..
.bbxx
...xx
2
1
0
0
0
4 5
.aab.
aabb.
.cbaa
cccaa
1
0
1
1
1
5 7
.c.....
ccdddd.
caabbcc
aabbacc
...aaa.
1
1
2
1
1
提示
In test cases worth 20% of total points, only the first figure will appear.
In test cases worth an additional 20% of total points, only the first two figures will appear.
In test cases worth an additional 20% of total points, only the first three figures will appear.
In test cases worth an additional 20% of total points, only the first four figures will appear.