Skip to content

Commit

Permalink
Merge branch 'main' into 48-tgyuuAn
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn authored May 3, 2024
2 parents d593d25 + 124514a commit bfe4a47
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 6 deletions.
26 changes: 26 additions & 0 deletions H0ngJu/DP/1,2,3 ๋”ํ•˜๊ธฐ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys

def input(): return sys.stdin.readline().strip()

T = int(input())

answer = []
dp = [0] * (11)

for index in range(T):
data = int(input())

for i in range(1, data + 1):
if i == 1:
dp[i] = 1
elif i == 2:
dp[i] = 2
elif i == 3:
dp[i] = 4
else:
dp[i] = dp[i-1] + dp[i-2] + dp[i-3]

answer.append(dp[data])

for a in answer:
print(a, end=" ")
15 changes: 9 additions & 6 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
## โœ๏ธ ๊ธฐ๋ก

| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
| :---: | :--------: | :------: | :-------------------------------------------------------------------------: | :-------------------------------------------------: |
| 1์ฐจ์‹œ | 2024.03.05 | ํ | [ํ”„๋กœ์„ธ์Šค](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/151 |
| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
| :---: | :--------: | :------: | :-----------------------------------------------------------------------------------: | :-------------------------------------------------: |
| 1์ฐจ์‹œ | 2024.03.05 | ํ | [ํ”„๋กœ์„ธ์Šค](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/151 |
| 2์ฐจ์‹œ | 2024.03.07 | ํ | [๋‹ค๋ฆฌ๋ฅผ ์ง€๋‚˜๋Š” ํŠธ๋Ÿญ](https://school.programmers.co.kr/learn/courses/30/lessons/42583) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/153 |
| 3์ฐจ์‹œ | 2024.03.10 | ํž™ | [N๋ฒˆ์งธ ํฐ ์ˆ˜](https://www.acmicpc.net/problem/2075) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/156 |
| 4์ฐจ์‹œ | 2024.03.13 | ํž™ | [๋ฌธ์ œ์ง‘](https://www.acmicpc.net/problem/1766) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/158 |
| 5์ฐจ์‹œ | 2024.03.16 | ๊ตฌํ˜„ | [์š”์„ธํ‘ธ์Šค ๋ฌธ์ œ](https://www.acmicpc.net/problem/1158) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/161 |
| 3์ฐจ์‹œ | 2024.03.10 | ํž™ | [N๋ฒˆ์งธ ํฐ ์ˆ˜](https://www.acmicpc.net/problem/2075) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/156 |
| 4์ฐจ์‹œ | 2024.03.13 | ํž™ | [๋ฌธ์ œ์ง‘](https://www.acmicpc.net/problem/1766) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/158 |
| 5์ฐจ์‹œ | 2024.03.16 | ๊ตฌํ˜„ | [์š”์„ธํ‘ธ์Šค ๋ฌธ์ œ](https://www.acmicpc.net/problem/1158) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/161 |
| 6์ฐจ์‹œ | 2024.03.19 | ์Šคํƒ | [์˜คํฐ์ˆ˜](https://www.acmicpc.net/problem/17298) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/164 |
| 7์ฐจ์‹œ | 2024.03.22 | DP | [1,2,3 ๋”ํ•˜๊ธฐ](https://www.acmicpc.net/problem/9095) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/166 |
| 8์ฐจ์‹œ | 2024.03.16 | DP | [์‰ฌ์šด ๊ณ„๋‹จ ์ˆ˜](https://www.acmicpc.net/problem/10844) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/170 |

---
28 changes: 28 additions & 0 deletions H0ngJu/์‰ฌ์šด ๊ณ„๋‹จ ์ˆ˜.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys

DIV = 1_000_000_000

N = int(sys.stdin.readline().rstrip())

dp = [[0] * 10 for _ in range(N+1)]
answer = 0

for i in range(1,N+1):
if i == 1:
for k in range(1,10):
dp[i][k] = 1

else:
for num in range(10):
if num == 0:
dp[i][num] = dp[i-1][1]%DIV
elif num == 9:
dp[i][num] = dp[i-1][8]%DIV
else:
dp[i][num] = (dp[i-1][num-1] + dp[i-1][num+1])%DIV

for k in range(10):
answer += dp[N][k]

print(answer%DIV)

25 changes: 25 additions & 0 deletions H0ngJu/์˜คํฐ์ˆ˜.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys
from collections import *

def input(): return sys.stdin.readline().strip()
N = int(input())

arr = list(map(int, input().split()))
arr.reverse()
answer = [-1 for _ in range(N)]

id = 0

stack = []
stack.append((id,arr.pop()))

while arr:
id += 1
arr_data = arr.pop()
while stack and stack[-1][1] < arr_data:
index, data = stack.pop()
answer[index] = arr_data
stack.append((id, arr_data))

for i in answer:
print(i, end=" ")
2 changes: 2 additions & 0 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@
| 43์ฐจ์‹œ | 2024.03.10 | ์ด๋ถ„ ํƒ์ƒ‰ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/64062">์ง•๊ฒ€๋‹ค๋ฆฌ ๊ฑด๋„ˆ๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/157
| 44์ฐจ์‹œ | 2023.03.13 | ํŠธ๋ผ์ด | <a href="https://www.acmicpc.net/problem/14725">๊ฐœ๋ฏธ๊ตด</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/159
| 45์ฐจ์‹œ | 2023.03.16 | ํŠธ๋ผ์ด | <a href="https://www.acmicpc.net/problem/31413">ํŠธ๋ผ์ด</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/162
| 46์ฐจ์‹œ | 2023.03.20 | ํŠธ๋ผ์ด | <a href="https://www.acmicpc.net/problem/27652">AB</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/165
| 47์ฐจ์‹œ | 2023.03.22 | ์ˆ˜ํ•™, ๋ถ„ํ• ์ •๋ณต | <a href="https://www.acmicpc.net/problem/15824">๋„ˆ ๋ด„์—๋Š” ์บก์‚ฌ์ด์‹ ์ด ๋ง›์žˆ๋‹จ๋‹ค</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/167
| 48์ฐจ์‹œ | 2023.03.25 | ๋ฒจ๋งŒ ํฌ๋“œ | <a href="https://www.acmicpc.net/problem/1738">๊ณจ๋ชฉ๊ธธ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/171
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys

DIV = 1_000_000_007

def input(): return sys.stdin.readline().rstrip()

def power(n, over):
if over == 0: return 1
elif over == 1: return n
elif over %2 == 0:
half = (power(n, over//2) % DIV)
return (half * half) % DIV
else:
half = (power(n, over//2) % DIV)
return (half * half * (n % DIV)) % DIV

N = int(input())
numbers = sorted(list(map(int,input().split())))
DP = [-1 for _ in range(N)]
answer = 0

for start_idx in range(N):
start_num = numbers[start_idx]
end_num = numbers[N-start_idx-1]

# ๋งŒ์•ฝ ์บ์‹ฑ์ด ๋˜์–ด์žˆ์ง€ ์•Š์„ ๊ฒฝ์šฐ ์ง์ ‘ ๊ณ„์‚ฐ
if DP[N-start_idx-1] == -1: DP[N-start_idx-1] = power(2, N-start_idx-1)

# ํ•œ๋ฒˆ์ด๋ผ๋„ ๊ณ„์‚ฐ ํ–ˆ์œผ๋ฉด ๋ฐ”๋กœ ์ด์šฉ
answer += ((end_num % DIV) * (DP[N-start_idx-1] % DIV)) % DIV
answer -= ((start_num % DIV) * (DP[N-start_idx-1] % DIV)) % DIV

print(answer % DIV)
80 changes: 80 additions & 0 deletions tgyuuAn/ํŠธ๋ผ์ด/AB.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import sys
from collections import defaultdict

class Node():
def __init__(self, key = None):
self.key = key
self.count = 0
self.children = {}

class Tries():
def __init__(self):
self.head = Node(None)

def add(self, element):
now = self.head

for char in element:
if char not in now.children:
now.children[char] = Node(char)

now = now.children[char]
now.count += 1

def delete(self, element):
now = self.head

for char in element:
child = now.children[char]
child.count -= 1
if child.count == 0: del now.children[char]
now = child

def find(self, element):
now = self.head
dic = defaultdict(int)

string = ""
for char in element:
if char not in now.children: return dic

string = string + char
now = now.children[char]
dic[string] = now.count

return dic

def input(): return sys.stdin.readline().rstrip()

def query(method, target, element):
if method == "add": target.add(element)

if method == "delete": target.delete(element)

if method == "find":
n = len(element)
a_result = A.find(element)
b_result = B.find(element[::-1])

answer = 0
for a_len in range(1,n):
answer += a_result[element[:a_len]] * b_result[element[:a_len-1:-1]]

print(answer)

N = int(input())
A = Tries()
B = Tries()
method, target, element = "", "", ""

for _ in range(N):
_input = input()
if _input[:4] == "find":
method,element = _input.split()
query(method, A, element)

else:
method, target, element = _input.split()

if target == "A": query(method, A, element)
else: query(method, B, element[::-1])

0 comments on commit bfe4a47

Please sign in to comment.