Skip to content

Instantly share code, notes, and snippets.

View inspirit941's full-sized avatar

Donggeon Lee inspirit941

View GitHub Profile
import math
def solution(n, stations, w):
result = 0
distance = []
# 설치된 기지국 사이에 전파가 닿지 않는 거리를 저장한다
for i in range(1, len(stations)):
distance.append((stations[i]-w-1) - (stations[i-1]+w))
# 맨 앞 기지국에서 첫 번째 아파트 사이에 전파가 닿지 않는 거리,
import sys
from collections import deque
from copy import deepcopy
n, m = map(int, sys.stdin.readline().split())
dirs = [(0,-1), (-1,0), (0,1), (1,0)]
back = {0:(1, 0), 1:(0,-1), 2:(-1,0),3:(0,1)}
# a = {0:"북",1:'동',2:'남',3:"서"}
# 현재 청소기 좌표
y, x, head = map(int, sys.stdin.readline().split())
class Node:
def __init__(self, char, data = None):
# 노드의 글자
self.char = char
# 마지막 노드일 때 string 값
self.data = data
# 해당 노드를 거쳐갈 경우 가능한 글자의 개수
self.possible_word = 0
# trie의 자식 노드들
self.children = {}
def solution(words, queries):
result = []
for query in queries:
answer = 0
length = len(query)
# 맨 앞글자가 ?인 경우
if query[0] == "?":
# 문자열을 뒤집는다
query = query[::-1]
# 필요한 문자열만 취한 뒤 다시 뒤집는다
# from itertools import chain
from collections import defaultdict
class Node:
def __init__(self, char, length = None, data = None):
self.char = char
self.data = None
self.children = {}
# length값을 저장할 dictionary. 코드를 간소화하려고 defaultdict을 사용해
# 인자값이 없으면 0을 리턴하도록 했다.
self.length = defaultdict(int)
import sys
import math
from itertools import combinations
n = int(sys.stdin.readline())
maps = []
for _ in range(n):
maps.append(list(map(int, sys.stdin.readline().split())))
# 두 개의 그룹으로 나눌 사람의 리스트
people = list(range(n))
import sys
g = int(sys.stdin.readline())
p = int(sys.stdin.readline())
plane = []
for _ in range(p):
plane.append(int(sys.stdin.readline()))
def parent_find(x):
if x == parent[x]:
return x
import heapq
def solution(jobs):
n = len(jobs)
time, end, queue = 0, -1, []
# 처리한 프로세스 개수
count = 0
answer = 0
while count < n:
for i in jobs:
import sys
import math
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
b, c = map(int, sys.stdin.readline().split())
# 어쨌든 총감독 한 명씩은 필요함
result = len(arr)
# 총감독 한 명으로 부족한 방
rest = [i - b for i in arr if i - b > 0]
def solution(n, results):
# wins[key] = key가 이긴 사람들의 집합
# loses[key] = key가 이기지 못한 사람들의 집합
wins, loses = {}, {}
for i in range(1, n+1):
wins[i], loses[i] = set(), set()
for i in range(1, n+1):
for battle in results:
if battle[0] == i: # i의 승리. i가 이긴 사람들