Skip to content
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

14-wkdghdwns199 #59

Merged
merged 4 commits into from
Mar 27, 2024
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
3 changes: 2 additions & 1 deletion wkdghdwns199/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
| 10μ°¨μ‹œ | 2024.02.29 | μŠ€νƒ, 큐, 덱 | <a href="https://www.acmicpc.net/problem/18258">큐 2</a> | <a href="">2024.02.29</a> |
| 11μ°¨μ‹œ | 2024.03.03 | μŠ€νƒ, 큐, 덱 | <a href="https://www.acmicpc.net/problem/11866">μš”μ„Έν‘ΈμŠ€ 문제 0</a> | <a href="">2024.03.03</a> |
| 12μ°¨μ‹œ | 2024.03.06 | DP | <a href="https://www.acmicpc.net/problem/1010">닀리 놓기</a> | <a href="">2024.03.06</a> |
| 13μ°¨μ‹œ | 2024.03.09 | DP | <a href="https://www.acmicpc.net/problem/1932">μ •μˆ˜ μ‚Όκ°ν˜•</a> | <a href="">2024.03.09</a> |
| 13μ°¨μ‹œ | 2024.03.09 | DP | <a href="https://www.acmicpc.net/problem/1932">μ •μˆ˜ μ‚Όκ°ν˜•</a> | <a href="">2024.03.09</a> |
| 14μ°¨μ‹œ | 2024.03.13 | 집합과 맡 | <a href="https://www.acmicpc.net/problem/20920">μ˜λ‹¨μ–΄ μ•”κΈ°λŠ” κ΄΄λ‘œμ›Œ</a> | <a href="">2024.03.13</a> |
17 changes: 17 additions & 0 deletions wkdghdwns199/리뷰풀이/ACM-13975.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import sys
from heapq import *
input = sys.stdin.readline
T = int(input())
for _ in range(T):
N = int(input())
chapters = list(map(int, input().split()))
time_list = []
min_time=0
for chapter in chapters :
heappush(time_list, chapter)
while len(time_list) > 1 :
temp =0
temp += heappop(time_list) + heappop(time_list)
heappush(time_list, temp)
min_time += temp
print(min_time)
49 changes: 49 additions & 0 deletions wkdghdwns199/리뷰풀이/ACM-16235.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import sys
from collections import deque
input = sys.stdin.readline

dx = [-1,-1,-1,0,0,1,1,1]
dy = [-1,0,1,-1,1,-1,0,1]

N,M,K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
trees = [[deque() for _ in range(N)] for _ in range(N)]

for _ in range(M) :
x,y,z = map(int, input().split())
trees[x-1][y-1].append(z)

ground = [[5] * N for _ in range(N)]
for _ in range(K) :

for i in range(N) :
for j in range(N):
trees_length = len(trees[i][j])
for k in range(trees_length) :
if ground[i][j] >= trees[i][j][k] :
ground[i][j] -= trees[i][j][k]
trees[i][j][k] += 1
else :
for _ in range(k,trees_length):
ground[i][j] += trees[i][j].pop() // 2
break

for i in range(N):
for j in range(N) :
for z in trees[i][j] :
if z % 5 == 0:
for idx in range(8):
move_x = i + dx[idx]
move_y = j + dy[idx]
if 0 <= move_x < N and 0 <= move_y < N :
trees[move_x][move_y].appendleft(1)
ground[i][j] += A[i][j]

answer = 0
for i in range(N) :
for j in range(N):
answer += len(trees[i][j])
print(answer)



12 changes: 12 additions & 0 deletions wkdghdwns199/리뷰풀이/ACM-1629.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys
input = sys.stdin.readline

def power(A,B,C):
if (B == 1) : return A%C
else :
temp = power(A,B//2, C)
if (B%2 == 0) : return temp * temp % C
else : return temp * temp * A % C

A,B,C = map(int, input().split())
print(power(A,B,C))
20 changes: 20 additions & 0 deletions wkdghdwns199/집합과_맡/ACM-20902.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys
input = sys.stdin.readline
N,M = map(int, input().split())
word_count = {}
for _ in range(N):
word = input().rstrip()
if len(word) >= M :
if word in word_count :
word_count[word][0] += 1
else :
word_count[word] = [1,len(word)]
Comment on lines +8 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ €λŠ” μ •λ ¬ν•˜λŠ” 뢀뢄은 λ―Όμ„λ‹˜μ΄λž‘ λ˜‘κ°™μ€λ°μš”
λ”•μ…”λ„ˆλ¦¬μ—μ„œ get(value, μ—†μ„λ•Œμ‚¬μš©ν•  κ°’) 으둜 ν•˜λ©΄ 값이 λ“€μ–΄μžˆμ§€ μ•Šμ•„λ„ μ“Έ 수 μžˆλŠ”κ±Έλ‘œ
μ½”λ“œλ₯Ό μ’€ νŽΈν•˜κ²Œ μ“Έ κ±° κ°™μ•„μš”. ν™μ€€λ‹˜μ²˜λŸΌ κΈΈμ΄κΉŒμ§€ μ €μž₯ν•˜μ‹œλ©΄ 이 방법은 λͺ» μ”λ‹ˆλ‹€λ§Œ..

for _ in range(N):
    word = input().rstrip()
    if len(word) >= M :
        word_count[word] = word_count.get(word, 0) + 1

p.s νŒŒμ΄μ¬μ—μ„œ len ν•¨μˆ˜λ₯Ό μ“°λ©΄ μ‹œκ°„λ³΅μž‘λ„λŠ” μ–΄λ–»κ²Œ λ κΉŒμš”? O(1) μž…λ‹ˆλ‹€.
파이썬 κ°μ²΄λŠ” 길이가 λ³€ν•  λ•Œλ§ˆλ‹€ λ‚΄λΆ€μ˜ μΉ΄μš΄ν„°κ°€ μ¦κ°ν•˜λ―€λ‘œ 이미 μ €μž₯된 valueλ₯Ό κΊΌλ‚΄μ˜€λŠ” μž‘μ—…μ΄λΌ
길이λ₯Ό λ°˜ν™˜ν•˜λŠ” ν•¨μˆ˜κ°€ λΉ λ₯΄κ²Œ λŒμ•„κ°‘λ‹ˆλ‹€!


print()
for key in word_count :
print (key)

sorted_word_list = sorted(word_count, key=lambda key : (-word_count[key][0], -word_count[key][1], key))
Comment on lines +8 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

단어 길이λ₯Ό λ”°λ‘œ 배열에 정리λ₯Ό ν•΄λ‘μ…¨κ΅°μš”!!

    else: # 단어가 M이상인 경우
        if word in word_lst: # 단어가 μžˆλŠ” 경우
            word_lst[word] += 1
        else: # 단어가 μ—†λŠ” 경우
            word_lst[word] = 1

word_lst = sorted(word_lst.items(), key = lambda x : (-x[1], -len(x[0]), x[0])) # x[0] = 단어, x[1] = 단어 λΉˆλ„μˆ˜

μ΄λ ‡κ²Œ 넣어놓은 λ‹€μŒ λ‘λ²ˆμ§Έ μˆœμ„œλ‘œ
λ”•μ…”λ„ˆλ¦¬μ— key의 len이 κΈ΄κ±° λ¨Όμ € μ •λ ¬λ˜κ²Œ 정렬을 ν•΄μ€¬μŠ΅λ‹ˆλ‹€!!

print()
for word in sorted_word_list :
print(word)
Loading