-
Notifications
You must be signed in to change notification settings - Fork 5
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
11 ljedd2 #161
Open
LJEDD2
wants to merge
15
commits into
main
Choose a base branch
from
11-ljedd2_
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
11 ljedd2 #161
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4f20884
2024-08-03 νΌλ‘λ.py
LJEDD2 9ed98a6
2024-08-03
LJEDD2 0449806
2024-09-01 μ€ μΈμ°κΈ°.py
LJEDD2 2502f35
2024-09-01
LJEDD2 a25db22
2024-09-02 μ€μΈμ°κΈ° μ€νμμ .py
LJEDD2 524c9a3
2024-09-05 λ¬Έμ μ§.py
LJEDD2 6f3d215
2024-09-05
LJEDD2 97c1258
2024-09-07 μμμ΄ λ§€λ¬κΈ°.py
LJEDD2 079a6e5
2024-09-07
LJEDD2 0e8b014
2024-09-08 μμμ΄ λ§€λ¬κΈ°.py
LJEDD2 66752ba
2024-09-11 μΉ΄λ μ λ ¬νκΈ°.py
LJEDD2 1c975ac
2024-09-18 Nλ²μ§Έ ν°μ.py
LJEDD2 3f50541
2024-09-18
LJEDD2 8db95cc
2024-09-21 μΉ΄λ ν©μ²΄ λμ΄.py
LJEDD2 79029cf
Revert "2024-09-18"
LJEDD2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# λ κ°λ¨ν νμ΄ ... (λ¬Έμμ΄) | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
for _ in range(int(input())): | ||
cnt = 0 | ||
s = input().rstrip() | ||
while "[]" in s: | ||
s = s.replace("[]", "") | ||
cnt += 1 | ||
|
||
print(2**cnt) | ||
|
||
|
||
|
||
# import sys | ||
|
||
# input = sys.stdin.readline | ||
|
||
# for _ in range(int(input())): | ||
# s = input().rstrip() # κ΄νΈ λ¬Έμμ΄ | ||
|
||
# max_depth = 0 # μ΅λ κΉμ΄λ₯Ό μ μ₯ν λ³μ | ||
# tree = list() # νμ¬ μ΄λ¦° κ΄νΈλ₯Ό μ μ₯ν μ€νμ | ||
|
||
# for i in s: | ||
# # μ¬λ κ΄νΈμΌ κ²½μ° μ€νμ μ΄λ¦° κ΄νΈ μΆκ° | ||
# if i == '[': | ||
# tree.append('[') | ||
# continue | ||
# # λ«λ κ΄νΈμΌ κ²½μ° | ||
# max_depth = max(len(tree), max_depth) | ||
# # νμ¬ κΉμ΄μ μ΅λ κΉμ΄ μ€ ν° κ°μ μ μ₯νκ³ | ||
# tree.pop() # λ§μ§λ§ μ΄λ¦° κ΄νΈλ₯Ό μ κ±° | ||
|
||
# print(2 ** max_depth) # μμ μ΄λ£°λ κ°μ§ μμ±, κ°μ§2-.1κ°μ© λλ κ°μ§ | ||
# # κ²°κ΅μ 2μ depthμΉ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# 첫 λ²μ§Έ μ½λ | ||
def solution(k, dungeons): | ||
|
||
def DFS(k, cnt): | ||
nonlocal answer | ||
|
||
answer = max(answer, cnt) | ||
for i in range(len(dungeons)): | ||
# λμ = ["μ΅μ νμ νΌλ‘λ", "μλͺ¨ νΌλ‘λ"] | ||
min_fatigue, use_fatigue = dungeons[i][0], dungeons[i][1] | ||
|
||
# νμ¬ νΌλ‘λκ° ν΄λΉ λμ μ λ°©λ¬ΈνκΈ° μν μ΅μ νΌλ‘λλ³΄λ€ ν΄ λ | ||
if not visited[i] and k >= min_fatigue: | ||
visited[i] = True | ||
|
||
# λ°±νΈλνΉ : μ΄μ λ Έλλ‘ λ€μ backν λ, | ||
# ν΄λΉ λ Έλλ₯Ό λ°©λ¬ΈνκΈ° μ μ νΌλ‘λλ‘ λ€μ 볡ꡬ | ||
DFS(k-use_fatigue, cnt+1) | ||
visited[i] = False | ||
|
||
answer = 0 | ||
visited = [False] * len(dungeons) # visited | ||
DFS(k, 0) | ||
|
||
return answer | ||
|
||
|
||
# κ°μ λ μ½λ | ||
def solution(k, dungeons): | ||
def dfs(k, cnt): | ||
# ν¨μ λ΄λΆμμ κ°μ κ°±μ ν μ μλ λΉμ μ λ³μλ‘ μ μΈ | ||
nonlocal answer | ||
|
||
answer = max(answer, cnt) | ||
|
||
# enumerate()λ₯Ό νμ©νμ¬ κ° λμ μ μΈλ±μ€μ κ°μ λμμ λ°λ³΅ | ||
for i, (min_fatigue, use_fatigue) in enumerate(dungeons): | ||
|
||
if not visited[i] and k >= min_fatigue: | ||
|
||
visited[i] = True | ||
dfs(k - use_fatigue, cnt + 1) | ||
visited[i] = False | ||
|
||
answer = 0 | ||
visited = [False] * len(dungeons) | ||
dfs(k, 0) | ||
|
||
return answer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import sys, heapq | ||
input = sys.stdin.readline | ||
|
||
n = int(input()) | ||
heap = [] | ||
|
||
for _ in range(n): | ||
for number in map(int, input().split()): | ||
|
||
if len(heap) < n: # λΉκ΅ λμμ΄ λͺ¨μλ κ²½μ° | ||
heapq.heappush(heap, number) #κ·Έλλ‘ μΆκ° | ||
|
||
else: | ||
if number > heap[0]: # μ μΌ μμκ²λ³΄λ€ ν¬λ©΄ | ||
heapq.heapreplace(heap, number) #μμκ±° λΉΌκ³ ν°κ±° λ£μ΄μ€ | ||
|
||
print(heap[0]) # 맨μμ μλκ² Nλ²μ§Έλ‘ ν°λ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import sys | ||
import heapq | ||
input = sys.stdin.readline | ||
|
||
cards = list(int(input()) for _ in range(int(input().strip()))) # λ°μ΄ν° μ λ ₯λ°μ | ||
heapq.heapify(cards) # 리μ€νΈλ₯Ό νκ΅¬μ‘°λ‘ λ°κΏμ£Όλ ν¨μ | ||
|
||
result = 0 | ||
while len(cards) > 1 : | ||
f = heapq.heappop(cards) # 첫λ²μ§Έ λν±μ΄ | ||
s = heapq.heappop(cards) # λλ²μ§Έ λν±μ΄ | ||
|
||
result += f+s | ||
|
||
# λ°κΏμΉκΈ° νμκ° μ΅μκ° λκ²λ | ||
heapq.heappush(cards, f+s) | ||
|
||
print(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import heapq | ||
n, m = map(int,input().split()) | ||
|
||
#ν κ΅¬μ‘°λ‘ λ³ν | ||
numbers = list(map(int,input().split())) | ||
heapq.heapify(numbers) | ||
|
||
for _ in range(m): | ||
|
||
x = heapq.heappop(numbers) | ||
y = heapq.heappop(numbers) | ||
|
||
# xμ y λ λ€ κ° κ΅μ²΄ | ||
heapq.heappush(numbers, x+y) | ||
heapq.heappush(numbers, x+y) | ||
|
||
print(sum(numbers)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# BOJ1766 λ¬Έμ μ§ | ||
# μμμ λ ¬ + μ°μ μμ ν | ||
|
||
import heapq | ||
|
||
n, m = map(int, input().split()) | ||
graph = [[] for _ in range(n + 1)] | ||
indegree = [0] * (n + 1) # μ§μ μ°¨μ 리μ€νΈ | ||
|
||
for i in range(m): | ||
s, e = map(int, input().split()) | ||
graph[s].append(e) | ||
indegree[e] += 1 # μ§μ μ°¨μ λ°μ΄ν° μ μ₯ | ||
|
||
# λ¬Έμ μμ κ°λ₯ν μ λ²νΈμ λ¬Έμ λΆν° νμ΄μΌ ν¨ -> μ°μ μμν,,? | ||
# 1~Nμ λμ΄λ μ λλ‘ | ||
|
||
queue = [] | ||
|
||
# μμ | ||
for i in range(1, n + 1): | ||
if indegree[i] == 0: | ||
heapq.heappush(queue, i) # μ§μ μ°¨μκ° 0μΈκ±° λ¨Όμ λμ΄λλ μ μ₯ | ||
|
||
while queue: | ||
now = heapq.heappop(queue) | ||
print(now, end=' ') | ||
|
||
for i in graph[now]: # μμ μ λ ¬ μν , μ§μ μ°¨μ μμ ! | ||
indegree[i] -= 1 | ||
|
||
if indegree[i] == 0: | ||
heapq.heappush(queue, i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# BOJ2252 μ€ μΈμ°κΈ° | ||
from collections import deque | ||
|
||
n, m = map(int, input().split()) | ||
graph = [[] for _ in range(n + 1)] | ||
indegree = [0] * (n + 1) # μ§μ μ°¨μ μ μ₯ν 리μ€νΈ | ||
|
||
for i in range(m): | ||
s,e = map(int, input().split()) | ||
graph[s].append(e) # zz | ||
indegree[e] += 1 # μ§μ μ°¨μ λ°μ΄ν°λ₯Ό μ μ₯ | ||
|
||
# Bλ₯Ό νκΈ° μν΄ AλΌλ μμ μ λ¨Όμ ν΄μΌ νλ κ΅¬μ‘°κ° μμ λ, | ||
# κ·Έ μμ μμλ₯Ό ꡬν΄μ£Όλ κ² = μμμ λ ¬ | ||
|
||
queue = deque() | ||
for i in range(1, n + 1): | ||
if not indegree[i]: | ||
queue.append(i) | ||
|
||
while queue: # μμ μ λ ¬ μν , μ§μ μ°¨μ μμ ! | ||
now = queue.popleft() | ||
print(now, end=' ') | ||
|
||
for next in graph[now]: | ||
indegree[next] -= 1 # μ§μ μ°¨μ 0μΈ μ μ νμ μ½μ | ||
if not indegree[next]: | ||
queue.append(next) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ°μ! νμ΄μ¬ heapq λͺ¨λ μ€μμ
heapreplace
ν¨μλΌλ κ²μ΄ μμκ΅°μ!μ μλ λλΆμ
heapreplace
ν¨μκ° heapμμ μ΅μκ°μ μ κ±°νκ³ itemμ μΆκ°νλ μν μ νλ€λ κ²μ μμκ°λλ€π«’λ€μμ μ λ νλ² μ¨λ³΄κ² μ΅λλ·!