From 0aa895663d4054a8583cf7e6f71e603bcb0b4f60 Mon Sep 17 00:00:00 2001 From: su-lim Date: Fri, 29 Sep 2023 03:47:32 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EB=B0=B1=EC=A4=80=2014499=20-=20=EC=A3=BC?= =?UTF-8?q?=EC=82=AC=EC=9C=84=20=EA=B5=B4=EB=A6=AC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- su-lim/14499.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 su-lim/14499.py diff --git a/su-lim/14499.py b/su-lim/14499.py new file mode 100644 index 0000000..90de867 --- /dev/null +++ b/su-lim/14499.py @@ -0,0 +1,61 @@ +import sys +input = sys.stdin.readline + +# init +N, M, y, x, K = map(int, input().split()) +maps = [] +for _ in range(N): + maps.append(list(map(int, input().split()))) +command = list(map(int, input().split())) + +dxdy = [(0,0), (1,0), (-1,0), (0,-1), (0,1)] +dices = [0,0,0,0,0,0] +result = [] + +def roll(direct, dices): + tmp_dices = dices.copy() + if direct == 1: #동 + tmp_dices[2] = dices[0] + tmp_dices[5] = dices[2] + tmp_dices[0] = dices[3] + tmp_dices[3] = dices[5] + if direct == 2: #서 + tmp_dices[3] = dices[0] + tmp_dices[0] = dices[2] + tmp_dices[5] = dices[3] + tmp_dices[2] = dices[5] + if direct == 3: #북 + tmp_dices[1] = dices[0] + tmp_dices[5] = dices[1] + tmp_dices[0] = dices[4] + tmp_dices[4] = dices[5] + if direct == 4: #남 + tmp_dices[4] = dices[0] + tmp_dices[0] = dices[1] + tmp_dices[5] = dices[4] + tmp_dices[1] = dices[5] + return tmp_dices + + +# main +for com in command: + + # 1. 이동할 수 있나? + dx, dy = dxdy[com] + if x+dx < 0 or y+dy < 0 or x+dx >= M or y+dy >= N: + continue + x += dx + y += dy + + # 2. 이동 후 주사위 결과 / roll + dices = roll(com, dices) + + # 3. 윗면 출력 + print(dices[0]) + + # 4. 바닥면 업데이트 + if maps[y][x] == 0: + maps[y][x] = dices[-1] + else: + dices[-1] = maps[y][x] + maps[y][x] = 0 \ No newline at end of file From 47a5fda131d46c243a9ee78846441bd0349c48ef Mon Sep 17 00:00:00 2001 From: yujeonghyeop Date: Fri, 29 Sep 2023 19:21:01 +0900 Subject: [PATCH 2/2] p14499 --- MIMO/14499.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 MIMO/14499.py diff --git a/MIMO/14499.py b/MIMO/14499.py new file mode 100644 index 0000000..d1d347f --- /dev/null +++ b/MIMO/14499.py @@ -0,0 +1,47 @@ +##문제 복기 : 주사위가 굴러갈 때마다 어떻게 되는지 알아내는게 포인트, 머릿속에서 잘 굴리다보면 규칙이 나온다. + +import sys +from collections import deque +wei = deque([4,1,3]) +hei = deque([2,1,5,6]) +dice = [0,0,0,0,0,0] +dx = [0,0,-1,1] +dy = [1,-1,0,0] +N,M,x,y,K = map(int, sys.stdin.readline().split()) +board = [] +for i in range(N): + a = list(map(int,sys.stdin.readline().split())) + board.append(a) +order = list(map(int, sys.stdin.readline().split())) +up = 1 +for j in order: + if x+dx[j-1] < 0 or x+dx[j-1] >=N or y+dy[j-1]<0 or y+dy[j-1]>=M: + continue + else: + x += dx[j-1] + y += dy[j-1] + if j == 1: + cnt = wei.pop() + cnt1 = hei.pop() + hei.append(cnt) + wei.appendleft(cnt1) + hei[1] = wei[1] + elif j == 2: + cnt = wei.popleft() + cnt1 = hei.pop() + wei.append(cnt1) + hei.append(cnt) + hei[1] = wei[1] + elif j == 3: + hei.append(hei.popleft()) + wei[1] = hei[1] + elif j == 4: + hei.appendleft(hei.pop()) + wei[1] = hei[1] + up = hei[1] + print(dice[up-1]) + if board[x][y] == 0: + board[x][y] = dice[7-up-1] + else: + dice[7-up-1] = board[x][y] + board[x][y] = 0 \ No newline at end of file