[백준 1053번] 팰린드롬 공장 (Python3)
from itertools import * def DFS(start,end,DP): for i,j in [(1,0),(0,1),(1,1)]: if DP[start+i][end-j]==N: DFS(start+i,end-j,DP) DP[start][end] = min(DP[start][end],DP[start+i][end-j]+int(not(i and j and seq[start]==seq[end]))) def palin(): if N==1: return 0 DP = [[N*int(i
[백준 13308번] 주유소 (Python3)
import sys input = sys.stdin.readline from heapq import * def dij(): hq = [(0,cost[0],0)]; DP = [[1e12]*N for i in range(cost[0]+1)] while hq: w,c,now = heappop(hq) if now==N-1: return w if DP[c][now] w+w1*c: DP[c1][next] = w+w1*c heappush(hq,(w+w1*c,c1,next)) N,M = map(int,input().split()) cost = [*map(int,input()..