编程介的小学生 2017-01-03 07:08 采纳率: 20.5%
浏览 943
已采纳

Flip and Turn

Description

Let us define a set of operations on a rectangular matrix of printable characters.

A matrix A with m rows (1-st index) and n columns (2-nd index) is given. The resulting matrix B is defined as follows.

Transposition by the main diagonal (operation identifier is ‘1’): Bj,i = Ai,j
Transposition by the second diagonal (‘2’): Bn−j+1,m−i+1 = Ai,j
Horizontal flip (‘H’): Bm−i+1,j = Ai,j
Vertical flip (‘V’): Bi,n−j+1 = Ai,j
Rotation by 90 (‘A’), 180 (‘B’), or 270 (‘C’) degrees clockwise; 90 degrees case: Bj,m−i+1 = Ai,j
Rotation by 90 (‘X’), 180 (‘Y’), or 270 (‘Z’) degrees counterclockwise; 90 degrees case: Bn−j+1,i = Ai,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 — m and n (0 < m, n ≤ 300). Then there are m lines with n printable characters per line (we define a printable character as a symbol with ASCII code from 33 to 126 inclusive). There will be no additional symbols at these lines.

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

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-01-09 15:53
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vhdl+MODELSIM
  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题