1
+ # Authored by : chj3748
2
+ # Co-authored by : -
3
+ # http://boj.kr/8f470025f1ae478d8e24a0ff85d0d873
4
+ import sys
5
+
6
+ def input ():
7
+ return sys .stdin .readline ().rstrip ()
8
+
9
+ # 상하반전
10
+ def fun1 (arr ):
11
+ r_num = len (arr )
12
+ c_num = len (arr [0 ])
13
+ temp = [arr [- (row + 1 )] for row in range (r_num )]
14
+ return temp
15
+
16
+ # 좌우반전
17
+ def fun2 (arr ):
18
+ arr_N = len (arr )
19
+ arr_M = len (arr [0 ])
20
+ temp = [arr [row ][::- 1 ] for row in range (arr_N )]
21
+ return temp
22
+
23
+ # 오른쪽90, 시계방향 90
24
+ def fun3 (arr ):
25
+ arr_N = len (arr )
26
+ arr_M = len (arr [0 ])
27
+ temp = [[arr [- (col + 1 )][row ] for col in range (arr_N )] for row in range (arr_M )]
28
+ return temp
29
+
30
+ # 왼쪽 90, 반시계 90
31
+ def fun4 (arr ):
32
+ arr_N = len (arr )
33
+ arr_M = len (arr [0 ])
34
+ temp = [[arr [col ][- (row + 1 )] for col in range (arr_N )] for row in range (arr_M )]
35
+ return temp
36
+
37
+ # 서브 그룹 오른쪽90 회전
38
+ def fun5 (arr ):
39
+ r_num = len (arr )
40
+ c_num = len (arr [0 ])
41
+ h_rn = r_num // 2
42
+ h_cn = c_num // 2
43
+ temp = [[0 ] * c_num for _ in range (r_num )]
44
+ for row in range (r_num ):
45
+ for col in range (c_num ):
46
+ if row < h_rn and col < h_cn :
47
+ temp [row ][col ] = arr [row + h_rn ][col ]
48
+ elif row < h_rn and col >= h_cn :
49
+ temp [row ][col ] = arr [row ][col - h_cn ]
50
+ elif row >= h_rn and col < h_cn :
51
+ temp [row ][col ] = arr [row ][col + h_cn ]
52
+ elif row >= h_rn and col >= h_cn :
53
+ temp [row ][col ] = arr [row - h_rn ][col ]
54
+ return temp
55
+
56
+ # 서브 그룹 왼쪽90 회전
57
+ def fun6 (arr ):
58
+ r_num = len (arr )
59
+ c_num = len (arr [0 ])
60
+ h_rn = r_num // 2
61
+ h_cn = c_num // 2
62
+ temp = [[0 ] * c_num for _ in range (r_num )]
63
+ for row in range (r_num ):
64
+ for col in range (c_num ):
65
+ if row < h_rn and col < h_cn :
66
+ temp [row ][col ] = arr [row ][col + h_cn ]
67
+ elif row < h_rn and col >= h_cn :
68
+ temp [row ][col ] = arr [row + h_rn ][col ]
69
+ elif row >= h_rn and col < h_cn :
70
+ temp [row ][col ] = arr [row - h_rn ][col ]
71
+ elif row >= h_rn and col >= h_cn :
72
+ temp [row ][col ] = arr [row ][col - h_cn ]
73
+ return temp
74
+
75
+
76
+ N , M , R = map (int , input ().split ())
77
+ array = [input ().split () for _ in range (N )]
78
+ for operator in input ().split ():
79
+ array = locals ()['fun' + operator ](array )
80
+
81
+ for row in array :
82
+ print (' ' .join (row ))
0 commit comments