전체 글

IT Blog
https://www.acmicpc.net/problem/15686 15686번: 치킨 배달 크기가 N×N인 도시가 있다. 도시는 1×1크기의 칸으로 나누어져 있다. 도시의 각 칸은 빈 칸, 치킨집, 집 중 하나이다. 도시의 칸은 (r, c)와 같은 형태로 나타내고, r행 c열 또는 위에서부터 r번째 칸 www.acmicpc.net from itertools import combinations N, M = map(int, input().split()) mp = [] chickenpos =[] #치킨집 위치 housepos =[] # 집위치 distance ={} #(idx, dis) chickidx=[] for i in range(N): mp.append(list(map(int, input().split..
import copy def solution(key, lock): answer = True M = len(key) N = len(lock) mlen = 2 * M + (N-2) tmap = [[-1 for i in range(mlen)] for j in range(mlen)] for i in range(M-1, M - 1 + N): for j in range(M-1, M - 1 + N): tmap[i][j] = lock[i - M + 1][j - M + 1] for x in range(0, mlen - M + 1): for y in range(0,mlen - M + 1 ): for i in range(4): aftermap = insertkey(x,y,key, tmap, M) if check(afterm..
def solution(s): N = len(s) answer = N cut = 1 ansstr = '' while 1: lst = [] if cut == N + 1: break for i in range(0,N, cut): lst.append(s[i:i+cut]) dict ={} anslst ='' for j in range(len(lst)-1): if lst[j] == lst[j+1]: if lst[j] not in dict: dict[lst[j]] = 2 else: dict[lst[j]] += 1 elif lst[j] != lst[j+1]: if lst[j] in dict: anslst+=lst[j]+str(dict[lst[j]]) dict.pop(lst[j], None) else: anslst+=..
https://www.acmicpc.net/problem/1931 1931번: 회의실 배정 (1,4), (5,7), (8,11), (12,14) 를 이용할 수 있다. www.acmicpc.net N = int(input()) lst = [] for i in range(N): s,e = map(int, input().split()) diff =e - s lst.append((s,e, diff)) slst = sorted(lst, key = lambda x:(x[1], x[0], diff)) cnt = 0 pstart = slst[0][0] pend = slst[0][1] for i in range(1, N): if slst[i][0] >= pend: # print(slst[i][0],slst[i][1]) ..
N = int(input()) mp = [] dx = [1,-1, 0, 0] dy = [0,0, 1, -1] area = 0 arealst = [] cnt = 0 for i in range(N): mp.append(list(map(int, input()))) def dfs(x, y): global area mp[x][y] = 0 for i in range(4): nx = x + dx[i] ny = y + dy[i] if 0
from collections import deque def bfs(n,k): q = deque() q.append((n, 0)) visited =[0] * 100001 visited[n] = 1 while 1: x , t = q.popleft() if x == k: print(t) break else: if (x+1) = 0 and visited[x-1] == 0 : q.append((x-1, t+1)) visited[x-1] = 1 if 0 < 2*x < 100001 and visited[2*x] == 0 : q.append((2*x, t+1)) visited[..
dfs 풀이 answer= [] def solution(tickets): global answer start =[] N = len(tickets) for i in range(N): if tickets[i][0] == "ICN": for j in range(N): if j != i and tickets[i][1] == tickets[j][0]: start.append((tickets[i][1], i)) break start.sort(key = lambda x:x[0]) startidx = start[0][1] visited = [startidx] cur = tickets[startidx][1] ans = [tickets[startidx][0], tickets[startidx][1]] dfs(startidx..
ans = -1 def solution(begin, target, words): global ans if target not in words: return 0 else: dfs(begin, target, words, 0) return ans def checkwords(a, b): ret = 0 for i in range(len(a)): if a[i] == b[i]: ret +=1 if ret== (len(a)-1): return True else: return False def dfs(begin, target, words, cnt,visited=[]): global ans if begin == target: if ans > cnt or ans == -1: ans = cnt return for i in w..
밤밭황제
밤밭