Skip to content

Commit

Permalink
7/1 PS 기둥과 보
Browse files Browse the repository at this point in the history
ChoiEungi committed Jul 2, 2021
1 parent 29babc5 commit 7f88295
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions choieungi/NewThisIsCT/12_12 기둥과 보.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
def check_possible(ans):
for x, y, installed in ans:
if installed == 0:
if y == 0 or [x - 1, y, 1] in ans or [x, y, 1] in ans or [x, y - 1, 0] in ans:
continue

return False

elif installed == 1:
if [x, y - 1, 0] in ans or [x + 1, y - 1, 0] in ans or ([x - 1, y, 1] in ans and [x + 1, y, 1] in ans):
continue
return False
return True


def solution(n, build_frame):
answer = []
for x, y, stuff, operate in build_frame:
if operate == 0:
answer.remove([x, y, stuff])
if not check_possible(answer):
answer.append([x, y, stuff])

elif operate == 1:
answer.append([x, y, stuff])
if not check_possible(answer):
answer.remove([x, y, stuff])

return sorted(answer)

0 comments on commit 7f88295

Please sign in to comment.