-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbj_17276.py
More file actions
36 lines (28 loc) · 1020 Bytes
/
Copy pathbj_17276.py
File metadata and controls
36 lines (28 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
from collections import deque
sys.stdin = open('bj_17276_in.txt', 'r')
input = sys.stdin.readline
tc = int(input().strip())
for _ in range(tc):
n, degree = map(int, input().strip().split())
r = (degree // 45) % 8
# print(r)
center = n // 2 # 중심 좌표
# print(depth, center)
# 배열 입력
arr = [list(map(int, input().strip().split())) for _ in range(n)]
# print(arr)
# depth 세팅
for d in range(1, center + 1):
coords = [(center - d, center - d), (center - d, center), (center - d, center + d), (center, center + d),
(center + d, center + d), (center + d, center), (center + d, center - d), (center, center - d)]
target = deque(arr[x][y] for x, y in coords)
# print(target)
target.rotate(r)
# print(target)
# 회전한 값 원래 좌표에 세팅
for (x, y), val in zip(coords, target):
arr[x][y] = val
# 정답 출력
for line in arr:
print(*line)