-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
203 additions
and
6 deletions.
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
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=" ") |
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 |
---|---|---|
@@ -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 | | ||
|
||
--- |
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 @@ | ||
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) | ||
|
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,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=" ") |
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
33 changes: 33 additions & 0 deletions
33
tgyuuAn/์ํ/๋ ๋ด์๋ ์บก์ฌ์ด์ ์ด ๋ง์๋จ๋ค.py
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 @@ | ||
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) |
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,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]) |