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 | |
r, c, m = map(int, sys.stdin.readline().split()) | |
maps = [[0 for _ in range(c)] for _ in range(r)] | |
for _ in range(m): | |
y, x, s, d, z = map(int, sys.stdin.readline().split()) | |
maps[y-1][x-1] = (s, d-1, z) | |
dirs = [(-1,0),(1,0),(0,1),(0,-1)] | |
# 가장 가까운 거리의 상어 잡기 | |
def get_shark(column_idx, maps): |
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(stones, k): | |
_min, _max = 0, max(stones) | |
answer = 0 | |
while _min <= _max: | |
mid = (_min + _max) // 2 | |
arr = [] | |
zero_in_row = 0 | |
max_zeros = zero_in_row | |
for i in range(len(stones)): | |
if stones[i] >= mid: |
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(stones, k): | |
window = deque(stones[:k]) | |
loc_max = max(window) | |
global_min = loc_max | |
for i in range(k, len(stones)): | |
leftpop = window.popleft() | |
rightappend = window.append(stones[i]) | |
if leftpop == loc_max: | |
loc_max = max(window) |
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 rotate(maps): | |
return [list(reversed(i)) for i in zip(*maps)] | |
def solution(key, lock): | |
hole = 0 | |
for y in range(len(lock)): | |
for x in range(len(lock[0])): | |
if lock[y][x] == 0: | |
hole += 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 copy import deepcopy | |
import re | |
# 해당 조합의 중복여부를 확인하기 위한 리스트 | |
check = [] | |
def dfs_check(idx, candidates, arr, length): | |
global answer, check | |
# 조합 끝까지 전부 확인한 경우 | |
if idx == len(candidates): | |
# banned_id 길이와 일치하고, 중복된 조합이 아닐 경우 |
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.setrecursionlimit(1500) | |
# 방을 찾는 함수 | |
def find_empty_room(x, rooms): | |
# 현재 방넘버 x에 아무도 배정되지 않은 경우 | |
if x not in rooms: | |
# 현재 방넘버 기준, 다음으로 빈 방 좌표를 저장한다. | |
rooms[x] = x + 1 | |
# 현재 방넘버 x를 반환한다. | |
return x |
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(s): | |
s = s[2:-2].split("},{") | |
sorted_s = sorted(s, key = lambda x: len(x)) | |
answer = [] | |
check = set() | |
for value in sorted_s: | |
for each_value in value.split(","): | |
if each_value not in check: | |
answer.append(int(each_value)) | |
check.add(each_value) |
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 get_doll(idx, board): | |
for i in range(len(board[idx-1])): | |
# 해당 인형이 있으면, 인형의 위치 값을 0으로 수정하고 | |
# 그 인형의 값을 리턴한다. | |
if board[idx-1][i] != 0: | |
value = board[idx-1][i] | |
board[idx-1][i] = 0 | |
return value | |
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, M = map(int, input().split()) | |
dirs = [(1,0), (-1,0), (0,1), (0,-1)] | |
dist = [[0 for _ in range(M)] for _ in range(N)] | |
maps = [list(map(int, list(input()))) for _ in range(N)] | |
queue = deque() | |
queue.append((0,0)) | |
dist[0][0] = 1 | |
while queue: | |
cur_y, cur_x = queue.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
from itertools import combinations | |
import sys | |
L, C = map(int, sys.stdin.readline().split()) | |
arr = sys.stdin.readline().split() | |
arr.sort() | |
vowel = {'a','e','i','o','u'} | |
consonant = set(list("abcdefghijklmnopqrstuvwxyz")) - vowel | |
candidate = combinations(range(len(arr)), L) | |
for value in candidate: |