#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>
using namespace std;
typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;
const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;
template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }
char F[128][128];
int dist[128][128];
int main() {
int R = in();
int C = in();
int sr = in() - 1;
int sc = in() - 1;
int gr = in() - 1;
int gc = in() - 1;
for (int i = 0; i < R; ++i) {
scanf("%s", F[i]);
fill(dist[i], dist[i] + C, INF);
}
queue<int> qr, qc;
qr.push(sr);
qc.push(sc);
dist[sr][sc] = 0;
while (!qr.empty()) {
int r = qr.front(); qr.pop();
int c = qc.front(); qc.pop();
const int DR[] = {1, 0, -1, 0}, DC[] = {0, 1, 0, -1};
if (r == gr && c == gc) {
printf("%d\n", dist[r][c]);
return 0;
}
for (int d = 0; d < 4; ++d) {
int rr = r + DR[d], cc = c + DC[d];
if (F[rr][cc] == '.' && dist[rr][cc] > dist[r][c] + 1) {
dist[rr][cc] = dist[r][c] + 1;
qr.push(rr);
qc.push(cc);
}
}
}
return 0;
}
./Main.cpp: In function ‘int in()’:
./Main.cpp:34:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int in() { int x; scanf("%d", &x); return x; }
^
./Main.cpp: In function ‘double fin()’:
./Main.cpp:35:42: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
double fin() { double x; scanf("%lf", &x); return x; }
^
./Main.cpp: In function ‘Int lin()’:
./Main.cpp:36:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
Int lin() { Int x; scanf("%lld", &x); return x; }
^
./Main.cpp: In function ‘int main()’:
./Main.cpp:49:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", F[i...