#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair P; int ok[51][51][3601]; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main(){ int h, w, a, b; int sx, sy, gx, gy; cin >> h >> w; cin >> a >> sx >> sy; cin >> b >> gx >> gy; vector s(h); rep(i,h) cin >> s[i]; ok[sx][sy][a] = 1; queue

que; que.push(make_pair(sx*100+sy, a)); while (!que.empty()) { auto p = que.front(); que.pop(); rep(i, 4) { int x = p.first / 100 + dx[i]; int y = p.first % 100 + dy[i]; if (x < 0 || y < 0 || x >= h || y >= w) continue; int cost = p.second + (s[x][y] == '*' ? 1 : -1); if (cost <= 0 || cost > 3500) continue; if (ok[x][y][cost]) continue; ok[x][y][cost] = 1; que.push(make_pair(x*100+y, cost)); } } if (ok[gx][gy][b]) cout << "Yes" << endl; else cout << "No" << endl; return 0; }