Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Flip and Turn
Description Let us define a set of operations on a rectangular matrix of printable characters. A matrix - Transposition by the main diagonal (operation identifier is ‘
`1` ’):*B*_{j}_{,i}=*A*_{i}_{,j} - Transposition by the second diagonal (‘
`2` ’):*B*_{n}_{−j+1,m−i+1}=*A*_{i}_{,j} - Horizontal flip (‘
`H` ’):*B*_{m−i+1,j}=*A*_{i}_{,j} - Vertical flip (‘
`V` ’):*B*_{i}_{,n−j+1}=*A*_{i}_{,j} - Rotation by 90 (‘
`A` ’), 180 (‘`B` ’), or 270 (‘`C` ’) degrees clockwise; 90 degrees case:*B*_{j}_{,m−i+1}=*A*_{i}_{,j} - Rotation by 90 (‘
`X` ’), 180 (‘`Y` ’), or 270 (‘`Z` ’) degrees counterclockwise; 90 degrees case:*B*_{n}_{−j+1,i}=*A*_{i}_{,j}
You are given a sequence of no more than 100 000 operations from the set. Apply the operations to the given matrix and output the resulting matrix. Input At the first line of the input file there are two integer numbers — The next line contains the sequence operations to be performed, specified by their one-character identifiers. The operations should be performed from left to right. Output Two integer numbers, the number of rows and columns in the output matrix. Then the output matrix must follow, in the same format as the input one. Sample Input 3 4 0000 a0b0 cdef A1 Sample Output 3 4 cdef a0b0 0000 Source Northeastern Europe 2005, Northern Subregion |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator