From c345919c41195ebfe9bf084c19c4b6bce0502874 Mon Sep 17 00:00:00 2001 From: H0ngJu Date: Fri, 6 Sep 2024 16:02:10 +0900 Subject: [PATCH] 2024-09-06 --- H0ngJu/README.md | 10 +-- ...61\353\213\210\353\260\224\355\200\264.py" | 64 +++++++++++++++++++ 2 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 "H0ngJu/\352\265\254\355\230\204/\355\206\261\353\213\210\353\260\224\355\200\264.py" diff --git a/H0ngJu/README.md b/H0ngJu/README.md index 957950e0..387bf4d3 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -24,9 +24,11 @@ | 20차시 | 2024.06.03 | 백트래킹 | [스타트와 링크](https://www.acmicpc.net/problem/14889) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/206 | | 21차시 | 2024.06.07 | 그리디 | [행복 유치원](https://www.acmicpc.net/problem/13164) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/208 | | 22차시 | 2024.08.06 | 해시 | [의상](https://school.programmers.co.kr/learn/courses/30/lessons/42578) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/224 | -| 23차시 | 2024.08.10 | 해시 | [베스트앨범](https://school.programmers.co.kr/learn/courses/30/lessons/42579) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/227 | -| 24차시 | 2024.08.17 | BFS | [아기상어](https://www.acmicpc.net/problem/16236) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/233 | -| 25차시 | 2024.08.17 | DFS | [친구비](https://www.acmicpc.net/problem/16562) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/234 | -| 26차시 | 2024.08.24 | 그리디 | [신입사원](https://www.acmicpc.net/problem/1946) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/237 | +| 23차시 | 2024.08.10 | 해시 | [베스트앨범](https://school.programmers.co.kr/learn/courses/30/lessons/42579) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/227 | +| 24차시 | 2024.08.17 | BFS | [아기상어](https://www.acmicpc.net/problem/16236) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/233 | +| 25차시 | 2024.08.17 | DFS | [친구비](https://www.acmicpc.net/problem/16562) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/234 | +| 26차시 | 2024.08.24 | 그리디 | [신입사원](https://www.acmicpc.net/problem/1946) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/237 | + +| 29차시 | 2024.09.06 | 구현 | [톱니바퀴](https://www.acmicpc.net/problem/14891) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/245 | --- diff --git "a/H0ngJu/\352\265\254\355\230\204/\355\206\261\353\213\210\353\260\224\355\200\264.py" "b/H0ngJu/\352\265\254\355\230\204/\355\206\261\353\213\210\353\260\224\355\200\264.py" new file mode 100644 index 00000000..00242881 --- /dev/null +++ "b/H0ngJu/\352\265\254\355\230\204/\355\206\261\353\213\210\353\260\224\355\200\264.py" @@ -0,0 +1,64 @@ +import sys + +def input() : return sys.stdin.readline().rstrip() + +wheels = [list(int(r) for r in input()) for _ in range(4)] +score = 0 + +K = int(input()) +cmds = [list(map(int, input().split())) for _ in range(K)] + +def leftshift(arr): + tmp = arr[0] + for i in range(len(arr)-1): + arr[i] = arr[i+1] + arr[-1] = tmp + +def rightshift(arr): + tmp = arr[-1] + for i in range(len(arr) - 1, 0, -1): + arr[i] = arr[i-1] + arr[0] = tmp + + +for n, cmd in cmds: + n -= 1 + left_check = [False] * 4 + right_check = [False] * 4 + + if cmd == 1: + right_check[n] = True + else: + left_check[n] = True + + for i in range(n, 0, -1): + if wheels[i][6] != wheels[i-1][2]: + if left_check[i]: + right_check[i-1] = True + if right_check[i]: + left_check[i-1] = True + else: + break + + for i in range(n,3): + if wheels[i][2] != wheels[i+1][6]: + if left_check[i]: + right_check[i+1] = True + if right_check[i]: + left_check[i+1] = True + else: + break + + for i in range(4): + if left_check[i]: + leftshift(wheels[i]) + + if right_check[i]: + rightshift(wheels[i]) + + +for i in range(4): + if wheels[i][0] == 1: + score += 2**i + +print(score) \ No newline at end of file