[프로그래머스] 경사로의 개수 (Python)
dy,dx = [1,-1,0,0],[0,0,1,-1] mod = 10**9+7 def multiply(A,B): result = [[0]*L for i in range(L)] for y in range(L): for x in range(L): for i in range(L): result[y][x] += A[y][i]*B[i][x] result[y][x] %= mod return result def cal(A,N): if N==1: return A C1 = cal(A,N//2); C2 = multiply(C1,C1) return multiply(C2,A) if N%2 else C2 def solution(grid, D, k): global N,M,L N,M = len(grid),len(grid[0]); ..
[백준 3153번] 타워 디펜스 (Python)
d = [1,0,-1,0] dd = {(1,-1,-1,1):1,(1,1,-1,-1):2,(-1,1,1,-1):3,(-1,-1,1,1):4} def DFS(now): global id ID[now] = nowid = id stack.append(now) for next in graph[now]: if check[next]: continue if not ID[next]: id += 1 DFS(next) ID[now] = min(ID[now],ID[next]) if ID[now]==nowid: SCC.append([]) while 1: x = stack.pop() check[x] = 1; SCC[-1].append(x) if x==now: return def dfs(now): TF[now] = 1; TF[no..