얼렁뚱땅 백준 문제풀이

[백준 문제풀이] 얼렁뚱땅 14891 톱니바퀴 풀이

MOSTAR 2022. 9. 7. 15:01

https://www.acmicpc.net/problem/14891

 

14891번: 톱니바퀴

첫째 줄에 1번 톱니바퀴의 상태, 둘째 줄에 2번 톱니바퀴의 상태, 셋째 줄에 3번 톱니바퀴의 상태, 넷째 줄에 4번 톱니바퀴의 상태가 주어진다. 상태는 8개의 정수로 이루어져 있고, 12시방향부터

www.acmicpc.net

 

 

금방 풀어서 기부니가 죠아용

 

arr = [list(map(int,input())) for _ in range(4)]
time = int(input())

for i in range(time) :
    dict = {}
    what, how = map(int,input().split())
    dict[what-1] = how
    this_how = how
    # left
    for j in range(what-2,-1,-1) :
        if arr[j][2] != arr[j+1][6] :
            this_how = -this_how
        else :
            this_how = 0
        dict[j] = this_how
    this_how = how
    for j in range(what,4) :
        if arr[j-1][2] != arr[j][6] :
            this_how = -this_how
        else :
            this_how = 0
        dict[j] = this_how

    for k in range(4) :
        if dict[k] == 1 :
            arr[k] = [arr[k][7]] + arr[k][0:7]
        elif dict[k] == -1 :
            arr[k] = arr[k][1:] + [arr[k][0]]
count = 0
for k in range(4) :
    if arr[k][0] == 1 :
        count += 2**k

print(count)