8000 [23-02-22] seungyeon.py by seungueonn · Pull Request #126 · da-in/algorithm-study · GitHub
[go: up one dir, main page]

Skip to content

[23-02-22] seungyeon.py #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Programmers - 고득점 Kit/[그래프] 순위/seungyeon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
def main():
solution(5, [[4, 3], [4, 2], [3, 2], [1, 2], [2, 5]])

def solution(n, results):
answer = 0
board = [[0]*n for _ in range(n)]

for a,b in results:
board[a-1][b-1] = 1
board[b-1][a-1] = -1

for k in range(n):
for i in range(n):
for j in range(n):
if i == j or board[i][j] in [1,-1]:
continue
if board[i][k] == board[k][j] == 1:
board[i][j] = 1
board[j][i] = board[k][i] = board[j][k] = -1
for i in board:
if i.count(0) == 1:
answer += 1
return answer

if __name__ == "__main__":
main()
27 changes: 27 additions & 0 deletions Programmers - 고득점 Kit/[스택-큐] 프린터/seungyeon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def main():
print(solution([2, 1, 3, 2],2))


def solution(priorities, location):
answer = 1
m = max(priorities)

while True:
temp = priorities.pop(0)

if temp == m :
if location == 0:
return answer
answer += 1
location -= 1
m = max(priorities)
else:
priorities.append(temp)
if location == 0:
location = len(priorities ) -1
else:
location -= 1


if __name__ == "__main__":
main()
16 changes: 16 additions & 0 deletions Programmers - 고득점 Kit/[해시] 위장/seungyeon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def main():
print(solution([["yellow_hat", "headgear"], ["blue_sunglasses", "eyewear"], ["green_turban", "headgear"]]))

def solution(clothes):
arr = {}
for c, type in clothes:
arr[type] = arr.get(type, 0) + 1

answer = 1
for type in arr:
answer *= (arr[type] + 1)

return answer - 1

if __name__ == "__main__":
main()
0