#include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,n) for (int i = 0; i < n; i++) #define abs(x) ((x)<0?(-(x)):(x)) #define REP(i,v) for (unsigned i = 0; i < v.size(); i++) #define RL(i,v) for (unsigned i = 0; i < v.length(); i++) typedef long long ll; // EXAM #define MAX_SIZE 550 string field[MAX_SIZE]; bool visited[MAX_SIZE][MAX_SIZE]; int main() { #ifdef __LOCAL__ freopen("input.in", "r", stdin); #else freopen("exam.in", "r", stdin); freopen("exam.out", "w", stdout); #endif int N,M,A,B,SI,SJ,EI,EJ; cin>>N>>M>>A>>B; for(int i=0;i>field[i]; //cout<>SI>>SJ>>EI>>EJ; SI--;SJ--;EI--;EJ--; if(SI==EI && SJ == EJ) { cout<<0< > > pq; pq.push(make_pair(0,make_pair(SI,SJ))); visited[SI][SJ] = true; int dy[] = {0,-1,0,1}; int dx[] = {1,0,-1,0}; while(!pq.empty()) { pair > now = pq.top(); pq.pop(); int ii = now.second.first; int jj = now.second.second; ll cost = -now.first; //cout<=0 && nj>=0 && ni