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 datetime | |
def solution(lines): | |
# 요청 처리를 끝낸 시간 / 요청이 들어온 시간 저장 | |
end_times, start_times = [], [] | |
for i in lines: | |
tmp = i.split() | |
# et = 요청이 끝난 연월일시. dur = 요청이 처리되기까지의 시간. | |
et, dur = "".join(tmp[0]+"T"+tmp[1]), float(tmp[2][:-1]) | |
# datetime 형태로 변환 |
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 | |
import sys | |
import math | |
from copy import deepcopy | |
from itertools import combinations | |
n, c = map(int, input().split()) | |
maps = [] | |
starts = [] | |
dirs = [(1,0),(-1,0),(0,1),(0,-1)] | |
for y in range(n): |
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, deque | |
def bfs(start, tables, visited): | |
queue = deque() | |
queue.append((start, 0)) | |
visited.add(start) | |
# 가장 먼 노드의 개수를 세는 dictionary | |
numbers = defaultdict(lambda:0) | |
while queue: |
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 | |
def solution(s): | |
s = deque(list(s)) | |
stack = [] | |
stack.append(s.popleft()) | |
while s: | |
# stack이 비었으면 삽입 | |
if len(stack) == 0: | |
stack.append(s.popleft()) | |
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 math | |
from collections import deque | |
def bfs(start, maps, distance, K): | |
queue = deque() | |
queue.append(start) | |
# 처음 출발한 도시의 distance는 0 | |
distance[start] = 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
import sys | |
import math | |
from itertools import combinations | |
n, m = map(int, sys.stdin.readline().split()) | |
# 치킨집 위치, 집 위치 | |
chicken, house = [], [] | |
# 치킨집 위치 / 집 위치 저장 | |
for y in range(n): | |
tmp = list(map(int, sys.stdin.readline().split())) |
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 | |
from itertools import combinations | |
from collections import deque | |
n, m = map(int, sys.stdin.readline().split()) | |
maps, empty_wall, virus = [], [], [] | |
dirs = [(0,1),(1,0),(-1,0),(0,-1)] | |
for y in range(n): | |
tmp = list(map(int, sys.stdin.readline().split())) |
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 | |
def bfs(start, maps): | |
dirs = [(0,1),(1,0),(0,-1),(-1,0)] | |
queue = deque() | |
queue.append(start) | |
while queue: | |
y, x, cnt = queue.popleft() | |
maps[y][x] = 0 | |
for dy, dx in dirs: |
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 math | |
def solution(n, costs): | |
# 정렬했을 때 weight 가중치 작을수록 리스트 전면에 오도록 costs를 변경한다. | |
costs = [(w, f, t) for f, t, w in costs] | |
costs.sort() | |
result = 0 | |
# 이미 방문한 노드는 저장한다. | |
visited = set() | |
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 pandas as pd | |
from itertools import combinations | |
def solution(relation): | |
answer = [] | |
# 주어진 리스트를 데이터프레임으로 변환 | |
df = pd.DataFrame(relation) | |
# column 리스트, column 개수 | |
col_list, total_col = set(df.columns), len(df.columns) | |
OlderNewer