#include #include using namespace std; typedef pair pii; int h, w, sx, sy, gx ,gy; int fld[50][50]; int reached[50][50]; pii dd[]={{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; int abs(int a, int b){ return max(a-b, b-a); } void dfs(int pi, int pj, int i, int j){ if(!(0<=i&&i=2) return; if(dif==0){ int mv=abs(pi, i)+abs(pj, j); if(mv==2){ int mh=fld[(pi+i)/2][(pj+j)/2]; if(mh>=fld[pi][pj]) return; } } reached[i][j]=1; for(pii d: dd){ int ni, nj; ni=i+d.first; nj=j+d.second; dfs(i, j, ni, nj); dfs(i, j, ni+d.first, nj+d.second); } } int main(){ cin>> h>> w>> sx>> sy>> gx>> gy; sx--; sy--; gx--; gy--; string b[h]; for(int i=0; i> b[i]; } for(int i=0; i