package yukicoder; import java.util.ArrayDeque; import java.util.Queue; import java.util.Scanner; public class Main{ public static void main(String[] args)throws Exception{ new Main().solve(); } int V; void solve(){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); V=sc.nextInt(); int sx=sc.nextInt(); int sy=sc.nextInt(); int gx=sc.nextInt(); int gy=sc.nextInt(); int[][] level=new int[n][n]; for(int i=0;i q; final long INF=Long.MAX_VALUE/4; int[][] table; int w,h; int[][] arrived; BFS(int[][] table){ h=table.length; w=table[0].length; this.table=table; q=new ArrayDeque(h*w); arrived=new int[h][w]; for(int i=0;i=w||ny>=h)continue; if(arrived[ny][nx]>=v.hp-table[ny][nx])continue; arrived[ny][nx]=v.hp-table[ny][nx]; q.add(new Vertice(nx, ny, v.d+1,v.hp-table[ny][nx])); } } return ans; } } class Vertice{ int x; int y; int d; int hp; Vertice(int x,int y,int d,int hp){ this.x=x; this.y=y; this.d=d; this.hp=hp; } } }