F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Tetris

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 476    Accepted Submission(s): 192


Problem Description
Tetris (Russian: §´e§ä§â§Ú§ã) is a puzzle video game originally designed and programmed by Alexey Pajitnov in the Soviet Union. The Tetris game is a popular use of tetrominoes, the four element special case of polyominoes.The seven kinds of tetrominoes are listed below.



We use ¡®I¡¯, ¡®J¡¯, ¡®L¡¯, ¡®O¡¯ to stand for the tetrominoes in the top row, and ¡®S¡¯, ¡®T¡¯, ¡®Z¡¯ for the ones in the bottom row.
I enjoy it a lot. But unfortunately, I am not so good at it. So I want a computer program to help me in this game. Given the shapes and falling order of some tetrominoes, and the width and height of a rectangle, the program should check out whether those tetrominoes can fully fill in that rectangle.
There are rules. First of all, you can rotate or move a tetromino, but you can¡¯t flip it. Secondly, let¡¯s assume the height of the screen is unlimited, so there is always enough space to rotate or move a tetromino. Thirdly, to simplify the problem, any tetromino should not be placed under other tetrominos which fell earlier than it. For example:



In the graph above, T is placed under S. If T fell earlier than S, that¡¯s OK. But if T came latter than S, that¡¯s not allowed.
To make it easy, you get only ten tetrominoes in the game. So the area of the rectangle to be filled in is always 40.
 

Input
The input contains no more than 1000 test cases.Each test case contains two lines which are formatted as follows.
n m
t1 t2 ...... t10
n, m are integers indicating the width and height of the rectangle. It is promised that n*m=40. The next line contains 10 characters, each indicating a tetromino. t1 is the first falling tetromino and t10 is the last.
The input is ended by n=0 and m=0
 

Output
For each test case, if those tetrominoes can fill the rectangle, print Yes in a single line, else print No.
 

Sample Input
10 4 I I L Z O J O T T J 4 10 O Z J S T O I J I S 0 0
 

Sample Output
Yes No
 

Hint

Here is a picture illustrated the first case. It may be helpful for you to understand the problem.

 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-20 03:23:30, Gzip enabled