#include #include #include #include #include #include #include using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} #define f first #define s second signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout< a; vector> dis, dis2; priority_queue,pair>, vector,pair>>, greater,pair>>> Q; cin>>H>>W; a.resize(H); dis.resize(H, vector(W, INF)); dis2.resize(H, vector(W, INF)); for(int i = 0; i < H; i++){ cin>>a[i]; } Q.push({{0,0},{0,0}}); dis[0][0] = 0; dis2[0][0] = 0; while(!Q.empty()){ pair,pair> P = Q.top(); Q.pop(); int d1 = P.first.first, d2 = P.first.second; int y = P.second.first, x = P.second.second; if(dis[y][x] < d1) continue; if(y == H-1 && x == W-1) break; for(int i = 0; i < 2; i++){ int ny = y + dy[i], nx = x + dx[i]; // cout<<"y = "<<> "< td) { dis[ny][nx] = td; Q.push({{td,0},{ny,nx}}); } } // cout<