#include "bits/stdc++.h" using namespace std; typedef pair P; class Edge { public: int to,cost; Edge(int t,int c) { to=t;cost=c; } }; vector g[40000]; //(i,j)=i*200+jでエンコード int d[40000]; //スタート地点から各点への距離 int m[200][200]; //グリッド //n頂点グラフのsからtへの01BFS最短距離 int bfs(int s,int t,int n) { deque

q; fill(d,d+n,1e8-1); //距離がllなら1e17-1 //01BFS d[s]=0; q.push_back(P(d[s],s)); while(!q.empty()) { P p=q[0]; //先頭を取り出す q.pop_front(); for(int i=0;i,greater

> q; fill(d,d+n,1e8-1); d[s]=0; q.push(P(d[s],s)); while(!q.empty()) { P p=q.top();q.pop(); if(p.first>d[p.second]) continue; for(int i=0;ip.first+e.cost) { d[e.to]=p.first+e.cost; q.push(P(d[e.to],e.to)); } } } return d[t]; } int main() { int n,v,ox,oy; cin>>n>>v>>ox>>oy; ox--;oy--; int s=0; //スタート地点(0,0) int t=200*(n-1)+(n-1); //ゴール地点(n-1,n-1) int o=200*ox+oy; int dx[4]={1,0,-1,0}; int dy[4]={0,-1,0,1};//右上左下 for(int i=0;i>m[j][i]; //iとjを入力に応じて入れ替える } /* スタートとゴールを0indexedに戻すのを忘れない!!! */ //グラフの作成 //この場合x方向が行となる。つまり下が右 for(int i=0;i-1 && nx-1 && ny0) { so=d[o]; ot=dijk(o,t,40000); } cerr<