#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define mind(a,b) (a>b?b:a) #define maxd(a,b) (a>b?a:b) #define absd(x) (x<0?-(x):x) #define pow2(x) ((x)*(x)) #define rep(i,n) for(int i=0; i=0; --i) #define repl(i,s,n) for(int i=s; i<=n; ++i) #define replr(i,s,n) for(int i=n; i>=s; --i) #define repf(i,s,n,j) for(int i=s; i<=n; i+=j) #define repe(e,obj) for(auto e : obj) #define SP << " " << #define COL << " : " << #define COM << ", " << #define ARR << " -> " << #define PNT(STR) cout << STR << endl #define POS(X,Y) "(" << X << ", " << Y << ")" #define DEB(A) " (" << #A << ") " << A #define DEBREP(i,n,val) for(int i=0; i P; //typedef pair P; typedef pair PI; typedef pair IP; typedef pair PP; typedef priority_queue, greater

> pvqueue; #define W 53 #define N 2203 int h, w; int a, si, sj, b, gi, gj; int used[W][W][N]; char m[W][W]; int dx[] = {-1,0,1,0}; int dy[] = {0,-1,0,1}; int main() { cin >> h >> w; cin >> a >> si >> sj >> b >> gi >> gj; rep(i, h) cin >> m[i]; queue que; que.push(PI(P(sj, si), a)); used[si][sj][a] = true; while(!que.empty()) { PI p = que.front(); que.pop(); int x = p.first.first, y = p.first.second, sz = p.second; rep(k, 4) { int nx = x + dx[k], ny = y + dy[k]; if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue; int n_sz = (m[ny][nx]=='*' ? sz+1 : sz-1); if(n_sz > (h+w+b+1)) n_sz = (h+w+b); if(n_sz>0 && !used[ny][nx][n_sz]) { que.push(PI(P(nx, ny), n_sz)); used[ny][nx][n_sz] = true; } } } cout << (used[gi][gj][b] ? "Yes" : "No") << endl; return 0; }