시뮬레이션
import sys
from collections import deque
input=sys.stdin.readline
wheels=[[]]
for i in range(4):
wheels.append(deque(list(input().strip())))
K=int(input())
for i in range(K):
num, dir=map(int,input().split())
moves = [0] * 5 # 회전할 톱니바퀴 방향 체크
moves[num] = dir
left=wheels[num][6]
for j in range(num-1,0,-1): # 맨왼쪽까지 비교
if wheels[j][2]==left: break # 극이 같으면 stop
moves[j]=-moves[j+1]
left=wheels[j][6]
right=wheels[num][2]
for j in range(num+1,5): # 맨오른쪽까지 비교
if wheels[j][6]==right: break # 극이 같으면 stop
moves[j]=-moves[j-1]
right=wheels[j][2]
for j in range(5):
if moves[j]!=0:
wheels[j].rotate(moves[j]) # 회전시키기
point=0
for i in range(1,5):
if wheels[i][0]=='1':
point+=pow(2,i-1)
print(point)
'IT > coding study' 카테고리의 다른 글
[SWEA] 2383. 점심 식사시간(python) (0) | 2022.09.16 |
---|---|
[SWEA] 2115. 벌꿀채취(python) (0) | 2022.09.05 |
[acmicpc] 17615. 볼 모으기(python) (0) | 2022.08.22 |
[acmicpc] 16234. 인구 이동(python) (0) | 2022.07.15 |
[programmers] 삼각 달팽이 (python) (0) | 2022.07.10 |