import sequtils,strutils,strscans,algorithm,math,future,sets,queues,tables,macros macro unpack*(rhs: seq,cnt: static[int]): auto = let t = genSym(); result = quote do:(let `t` = `rhs`;()) for i in 0.. 0: let (x,y,v,c) = opens.dequeue() if cost[x][y] < v : continue for d in diffSeq: let (nx,ny) = (d.x + x,d.y + y) if nx < 0 or ny < 0 or nx >= W or ny >= H : continue var n_v = v + L[nx][ny] if n_v >= V : continue if nx == gx-1 and ny == gy-1: echo c+1 quit() if n_v < cost[nx][ny] : cost[nx][ny] = n_v opens.enqueue((nx,ny,n_v,c+1)) seek(sx-1,sy-1,L,dxdy4) echo -1