#include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c p; int main(int argc, char const *argv[]) { ll h, w;std::cin >> h >> w; ll INF = 1000000000; vector v(h); re(i, h) std::cin >> v[i]; vvl cost = VV(h, w, INF, ll); queue

q; q.push(p(0, 0)); cost[0][0] = 0; while(!q.empty()){ p top = q.front(); q.pop(); ll x = top.first/10000, y = top.first%10000, c = top.second; if(c!=cost[x][y]) continue; // r if(x+1