[python] 3190. 뱀
문제 출처 3190. 뱀 풀이 N = int(input()) K = int(input()) apples = [tuple(map(int, input().split())) for _ in range(K)] L = int(input()) cmd = [input().split() for _ in range(L)] directions = { 'E': (0, 1), 'S': (1, 0), 'W': (0, -1), 'N': (-1, 0) } rotation = { 'E': {'L': 'N', 'D': 'S'}, 'S': {'L': 'E', 'D': 'W'}, 'W': {'L': 'S', 'D': 'N'}, 'N': {'L': 'W', 'D': 'E'}, } cnt = 0 snake = [(0, 0)] d = 'E' ..
2019. 7. 24.
[python] 15685. 드래곤 커브
문제 출처 15685. 드래곤 커브 풀이 N = int(input()) curves = [list(map(int, input().split())) for _ in range(N)] arr = [[0]*101 for _ in range(101)] directions = { 0: (1, 0), 1: (0, -1), 2: (-1, 0), 3: (0, 1) } def rotation(x, y, ex, ey): dx, dy = x-ex, y-ey nx, ny = ex-dy, ey+dx return nx, ny while curves: x, y, d, g = curves.pop(0) arr[y][x] = 1 gen = 0 q = [(x, y), (x+directions[d][0], y+directions[d][1]..
2019. 7. 24.
[python] 14888. 연산자 끼워넣기
문제 출처 14888. 연산자 끼워넣기 풀이 이 문제는 최솟값과 최댓값을 모두 출력해야 하므로 가능한 모든 경우를 다 계산해 봐야 한다. 최악의 경우는 10! / (4!4!3!) 로 주어진 시간안에 충분히 해결 가능하다. N = int(input()) nums = list(map(int, input().split())) add, sub, mul, div = map(int, input().split()) min_, max_ = 1e9, -1e9 def dfs(i, res, add, sub, mul, div): global max_, min_ if i == N: max_ = max(res, max_) min_ = min(res, min_) return else: if add: dfs(i+1, res+nums..
2019. 7. 24.