import sys
import copy
n, m, r = map(int, sys.stdin.readline().rstrip().split(" "))
def one(a):
tmp = []
for i in reversed(range(n)):
tmp.append(a[i])
return tmp
def two(a):
tmp = [[0 for _ in range(m)] for _ in range(n)]
for i in range(n):
for j in range(m):
tmp[i][m-1-j] = a[i][j]
return tmp
def three(a):
tmp = [[0 for _ in range(n)] for _ in range(m)]
for i in range(n):
t = (n-1) - i
for j in range(m):
tmp[j][t] = a[i][j]
return tmp
def four(a):
tmp = [[0 for _ in range(n)] for _ in range(m)]
for i in range(len(a)):
for j in range(len(a[0])):
tmp[len(a[0])-1-j][i] = a[i][j]
return tmp
def five(a):
tmp = [[0 for _ in range(m)] for _ in range(n)]
for i in range(n//2):
for j in range(m//2):
tmp[i][j+m//2] = arr[i][j]
for i in range(n//2):
t = (i+n//2)
for j in range(m//2, m):
tmp[t][j] = a[i][j]
for i in range(n//2, n):
for j in range(m//2, m):
tmp[i][j - m//2] = a[i][j]
for i in range(n//2, n):
for j in range(m//2):
tmp[i-n//2][j] = a[i][j]
return tmp
def six(a):
tmp = [[0 for _ in range(m)] for _ in range(n)]
for i in range(n//2):
for j in range(m//2):
tmp[i+n//2][j] = a[i][j]
for i in range(n//2):
for j in range(m//2, m):
tmp[i][j-m//2] = a[i][j]
for i in range(n//2, n):
for j in range(m//2, m):
tmp[i-n//2][j] = a[i][j]
for i in range(n//2, n):
for j in range(m//2):
tmp[i][j+m//2] = a[i][j]
return tmp
def move(arr):
a = []
for i in range(len(arr)):
a.append(arr[i])
return a
def show(a):
n = len(a)
m = len(a[0])
for i in range(n):
for j in range(m):
print(a[n][m], end = ' ')
print()
arr = []
for i in range(n):
arr.append(list(map(int, sys.stdin.readline().rstrip().split(" "))))
orders = list(map(int, sys.stdin.readline().rstrip().split(" ")))
for order in orders:
if order == 1:
a = one(arr)
arr = copy.deepcopy(a)
elif order == 2:
a = two(arr)
arr = copy.deepcopy(a)
elif order == 3:
a = three(arr)
arr = copy.deepcopy(a)
n,m = m,n
elif order == 4:
a = four(arr)
arr = copy.deepcopy(a)
n,m = m,n
elif order == 5:
a = five(arr)
arr = copy.deepcopy(a)
elif order == 6:
a = six(arr)
arr = copy.deepcopy(a)
for i in range(len(arr)):
for j in range(len(arr[0])):
print(arr[i][j] , end = ' ')
print()
문제에 대한 자세한 설명은 제 티스토리에 있습니다.
https://jiwonna52.tistory.com/14