This file contains hidden or 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
def solution(money): | |
table = [0 for _ in range(len(money))] | |
# 첫 번째 집을 털 경우 | |
table[0] = money[0] | |
table[1] = table[0] | |
for i in range(2, len(money) - 1): | |
table[i] = max(table[i-1], table[i-2] + money[i]) | |
value = max(table) | |
# 첫 번째 집을 털지 않을 경우 | |
table = [0 for _ in range(len(money))] |
This file contains hidden or 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
# data/data_preprocess/tokenization.py line 85 | |
def convert_by_vocab(vocab, items): | |
"""Converts a sequence of [tokens|ids] using the vocab.""" | |
output = [] | |
# print(type(vocab)) | |
for item in items: | |
# 사전에 없는 단어면 Exception을 띄우는 대신, unknown 토큰인 [UNK]를 반환하도록 변경해 줬다. | |
if item not in vocab: | |
vocab[item] = vocab["[UNK]"] | |
output.append(vocab[item]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
from collections import defaultdict | |
import copy | |
def dfs(start, table, arr, result, n_tickets): | |
# 이동한 경로를 저장함 | |
arr.append(start) | |
for i in range(len(table[start])): | |
# 이미 방문했으면 건너뛴다 | |
if table[start][i] == True: | |
continue | |
else: |
This file contains hidden or 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
import sys | |
from copy import deepcopy | |
import math | |
n, m = map(int, sys.stdin.readline().split()) | |
maps = [] | |
cctvs = [] | |
for y in range(n): | |
temp = list(map(int, sys.stdin.readline().split())) | |
for x in range(m): | |
if 1 <= temp[x] <= 5: |
This file contains hidden or 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
import sys | |
from collections import Counter | |
r, c, k = map(int, sys.stdin.readline().split()) | |
maps = [] | |
for _ in range(3): | |
temp = list(map(int, sys.stdin.readline().split())) | |
maps.append(temp) | |
time = 0 | |
find = False |
This file contains hidden or 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
import sys | |
sys.stdin = open('input.txt') | |
n = int(sys.stdin.readline()) | |
arr = list(map(int, sys.stdin.readline().split())) | |
answer = [0 for _ in range(len(arr))] | |
stack = [] | |
for i in range(len(arr)-1, -1, -1): | |
while stack and arr[stack[-1]] < arr[i]: | |
answer[stack.pop()] = i+1 |
This file contains hidden or 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
import sys | |
arr = list(sys.stdin.readline()) | |
stack = [] | |
answer = 0 | |
prev = None | |
for i in range(len(arr)): | |
if arr[i] == '(': | |
stack.append(arr[i]) | |
elif prev == '(' and arr[i] == ')': |
This file contains hidden or 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
import sys | |
from collections import deque, defaultdict | |
r, c = map(int, sys.stdin.readline().split()) | |
maps = [] | |
for _ in range(r): | |
maps.append(list(map(int, sys.stdin.readline().split()))) | |
def bfs(start, maps, visited): | |
ice = defaultdict(int) | |
queue = deque() |