[백준 1420번] 학교 가지마! (Python3)
from collections import * dy = [1,-1,0,0]; dx = [0,0,1,-1] def BFS(): visited = [-1]*N*M*2; visited[K+N*M] = K dq = deque([K+N*M]) while dq: now = dq.popleft() if now==H: return visited for next,c in graph[now]: if visited[next]y1>=0 and M>x1>=0 and board[y1][x1]!="#": graph[y1*M+x1+N*M].append((y*M+x,1)) graph[y*M+x].append((y1*M+x1+N*M,0)) flow = [{i:0 for i,c in graph[n]} for n in range(N*M*2..
[백준 14750번] Jerry and Tom (Python3)
import sys def input(): return [*map(int,sys.stdin.readline().split())] def ccw(x1,y1,x2,y2,x,y): return (x2-x1)*(y-y1)-(y2-y1)*(x-x1) def crossed(x1,y1,x2,y2,x3,y3,x4,y4): ccw12,ccw34 = ccw(x1,y1,x2,y2,x3,y3)*ccw(x1,y1,x2,y2,x4,y4),ccw(x3,y3,x4,y4,x1,y1)*ccw(x3,y3,x4,y4,x2,y2) if ccw12==0 and ccw34==0: if min(x1,x2)