๋ฌธ์
๋ฐฑ์ค ์จ๋ผ์ธ ์ ์ง - 16926๋ฒ
ํ์ด ๊ณผ์
๋ฐฐ์ด์ ํ์ ํ๋ ๋ก์ง์ ๊ตฌํํ๋ ๋ฌธ์ ์
๋๋ค.python
์ผ๋ก ์ ์ถํ๋ ์๊ฐ์ด๊ณผ๊ฐ ๋ฐ์ํ์ฌ pypy3
๋ก ์ ์ถํ์ต๋๋ค.
์ฝ๋
import sys
def rotate():
x, y = 0, 0
n, m = N, M
time = min(N, M) // 2
while time:
cache = board[x][y]
# ์์ชฝ
for i in range(m - 1):
board[x][y + i] = board[x][y + i + 1]
# ์ค๋ฅธ์ชฝ
for i in range(n - 1):
board[x + i][y + m - 1] = board[x + i + 1][y + m - 1]
# ์๋์ชฝ
for i in range(m - 1):
board[x + n - 1][y + m - 1 - i] = board[x + n - 1][y + m - 2 - i]
# ์ผ์ชฝ
for i in range(n - 1):
board[x + n - 1 - i][y] = board[x + n - 2 - i][y]
board[x + 1][y] = cache
n -= 2
m -= 2
x += 1
y += 1
time -= 1
def solution():
for _ in range(R):
rotate()
for row in board:
print(*row)
if __name__ == '__main__':
N, M, R = list(map(int, sys.stdin.readline().split()))
board = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
solution()
๋ฐ์ํ
'๐ algorithm > boj' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ 20006 - ๋ญํน์ ๋๊ธฐ์ด (0) | 2021.04.13 |
---|---|
BOJ 2869 - ๋ฌํฝ์ด๋ ์ฌ๋ผ๊ฐ๊ณ ์ถ๋ค (0) | 2021.04.13 |
BOJ 15732 - ๋ํ ๋ฆฌ ์จ๊ธฐ๊ธฐ (0) | 2021.03.18 |
BOJ 2178 - ๋ฏธ๋ก ํ์ (0) | 2021.03.18 |
BOJ 6593 - ์๋ฒ ๋น๋ฉ (0) | 2021.03.18 |
๐ฌ ๋๊ธ