[백준 9202번] Boggle (Python3)
import sys input = sys.stdin.readline dy = [1,1,1,0,-1,-1,-1,0]; dx = [1,-1,0,1,1,-1,0,-1] score = [0,0,0,1,1,2,3,5,11] def update(word): now = Dict for w in word: if not now.get(w): now[w] = {} now = now[w] now[0] = 1 def find(y,x,bit,now,word): if now.get(0): words.add(word) for i in range(8): y1,x1 = y+dy[i],x+dx[i] if 4>y1>=0 and 4>x1>=0: if bit&(1
[백준 16930번] 달리기 (Python3)
import sys input = sys.stdin.readline from collections import * dy = [1,-1,0,0]; dx = [0,0,1,-1] def BFS(): dq = deque() for i in range(4): y1,x1 = ys+dy[i],xs+dx[i] if N>y1>=0 and M>x1>=0 and not board[y1][x1]: dq.append((y1,x1,1,i,1)) visited = [[0]*M for i in range(N)] direction = [[[0]*4 for i in range(M)] for i in range(N)] while dq: y,x,cnt,d,k = dq.popleft() if y==ye and x==xe: return cnt..
[백준 14927번] 전구 끄기 (Python3)
import sys,copy input = sys.stdin.readline dy = [0,1,-1,0,0]; dx = [0,0,0,1,-1] def switch(y,x,board): for i in range(5): y1,x1 = y+dy[i],x+dx[i] if N>y1>=0 and N>x1>=0: board[y1][x1] ^= 1 def bitmask(bit): global result newboard = copy.deepcopy(board) cnt = 0 for x in range(N): if bit&(1