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
# 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]) |
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
def solution(sticker): | |
# table[i] = i번째 스티커를 떼는 경우 최댓값 | |
# 맨 앞 스티커를 떼는지 아닌지 -> 맨 뒤 스티커에 영향을 준다 | |
if len(sticker) == 1: | |
return sticker[0] | |
# 1. 맨 앞 스티커를 떼는 경우 | |
table1 = [0 for _ in range(len(sticker))] | |
table1[0] = sticker[0] | |
table1[1] = table1[0] | |
for i in range(2, len(sticker)-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
def solution(land): | |
for row in range(1, len(land)): | |
# 밟을 칸(index) 선택 | |
for i in range(4): | |
# 밟은 칸 제외한 나머지 칸 | |
rest = set(range(4)) - {i} | |
# 밟은 칸 제외한 나머지 칸들의 최댓값을 다음 row의 index에 저장. | |
land[row][i] += max([land[row-1][index] for index in rest]) | |
# 마지막 row에서 얻을 수 있는 점수의 최댓값을 확인한다. | |
return max(land[-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
def solution(land): | |
for row in range(1, len(land)): | |
# 밟을 칸(index) 선택 | |
for i in range(4): | |
# 밟은 칸 제외한 나머지 칸 | |
rest = set(range(4)) - {i} | |
# 밟은 칸 제외한 나머지 칸들의 최댓값을 다음 row의 index에 저장. | |
land[row][i] += max([land[row-1][index] for index in rest]) | |
# 마지막 row에서 얻을 수 있는 점수의 최댓값을 확인한다. | |
return max(land[-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
from collections import deque | |
n = int(input()) | |
maps = [] | |
for _ in range(n): | |
tmp = [int(i) for i in input()] | |
maps.append(tmp) | |
def bfs(coord, maps, visited): | |
dirs = [(1, 0), (-1,0), (0,1), (0,-1)] | |
queue = deque() |
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 | |
n = int(sys.stdin.readline().replace("\n","")) | |
for _ in range(n): | |
# 글자를 입력받는 stack left, 커서 이동할 때 사용할 stack right. | |
left, right = [], [] | |
string = list(sys.stdin.readline().replace("\n","")) | |
for value in string: | |
# 커서를 뒤로 옮길 경우, left에 값이 있다면 left 마지막 값을 right로 옮긴다. | |
if value == "<": | |
if len(left) != 0: |
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(n, times): | |
## 최악의 경우: 가장 비효율적인 심사관에게 다 받는 경우의 시간. | |
left, right = 1, max(times) * n | |
answer = 0 | |
while left <= right: | |
# 한 심사관에게 주어진 시간 | |
mid = (left + right) // 2 | |
people = 0 | |
for i in times: | |
# 각 심사관마다, 주어진 시간 동안 몇 명의 사람을 심사할 수 있는지 |