Skip to content

Commit

Permalink
2024-09-06
Browse files Browse the repository at this point in the history
  • Loading branch information
H0ngJu committed Sep 6, 2024
1 parent 39a3ee2 commit c345919
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 4 deletions.
10 changes: 6 additions & 4 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

---
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 c345919

Please sign in to comment.