Skip to content

Commit

Permalink
Merge pull request #245 from AlgoLeadMe/29-H0ngJu
Browse files Browse the repository at this point in the history
29-H0ngJu
  • Loading branch information
H0ngJu authored Sep 20, 2024
2 parents 9fe0fcb + d3b0a5d commit 9db5604
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
3 changes: 2 additions & 1 deletion H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
| 26μ°¨μ‹œ | 2024.08.24 | 그리디 | [μ‹ μž…μ‚¬μ›](https://www.acmicpc.net/problem/1946) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/237 |
| 27μ°¨μ‹œ | 2024.08.27 | DFS | [트리의 지름](https://www.acmicpc.net/problem/1967) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/240 |
| 28μ°¨μ‹œ | 2024.09.04 | λ²¨λ§Œν¬λ“œ | [νƒ€μž„λ¨Έμ‹ ](https://www.acmicpc.net/problem/11657) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/244 |
---
| 29μ°¨μ‹œ | 2024.09.06 | κ΅¬ν˜„ | [ν†±λ‹ˆλ°”ν€΄](https://www.acmicpc.net/problem/14891) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/245 |
---
64 changes: 64 additions & 0 deletions H0ngJu/κ΅¬ν˜„/ν†±λ‹ˆλ°”ν€΄.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 9db5604

Please sign in to comment.