728x90
반응형
1. 문제
2. 풀이
import sys
import collections
wheels = []
turns = []
def turnLeft(i, d):
if i < 0:
return
if wheels[i][2] != wheels[i+1][6]:
turnLeft(i-1, -d)
wheels[i].rotate(d)
def turnRight(i, d):
if i > 3:
return
if wheels[i][6] != wheels[i-1][2]:
turnRight(i+1, -d)
wheels[i].rotate(d)
def solve():
for turn in turns:
[idx, direction] = turn
turnLeft(idx-1, -direction)
turnRight(idx+1, -direction)
wheels[idx].rotate(direction)
if __name__ == '__main__':
for i in range(4):
wheels.append(collections.deque(list(sys.stdin.readline())[:8]))
K = int(sys.stdin.readline())
for i in range(K):
v1, v2 = map(int, sys.stdin.readline().split())
turns.append([v1-1, v2])
solve()
sumall = 0
for i, wheel in enumerate(wheels):
sumall += int(wheel[0]) * (1 << i)
print(sumall)
728x90
반응형
'Study > Algorithm & Data structure' 카테고리의 다른 글
[프로그래머스][heap] 게임아이템 python (201005) (0) | 2020.10.05 |
---|---|
[백준] 스타트와링크 python (201004) (0) | 2020.10.04 |
[프로그래머스][DP] 등굣길 python (201002) (0) | 2020.10.03 |
[프로그래머스] 없어진 기록 찾기 SQL - 200930 (0) | 2020.09.30 |
[백준][binary search] 나무자르기 python (200930) (0) | 2020.09.30 |
댓글