#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define siz(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll los(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;
int pref[1501][1501];
int pref2[1501][1501];
int pref3[1501][1501];
bool odw[1501][1501];
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//random_start();
int n,m,k,l;
int x1,y1,pom1,pom2;
cin >> n >> m >> k >> l >> pom1 >> y1 >> x1 >> pom2;
x1++;
y1++;
swap(n,m);
int x2,y2;
rep2(i,1,n) rep2(j,1,m)
{
char z;
cin >> z;
pref[i][j] = pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1]+(z == 'X');
if(z == '*')
{
x2 = j;
y2 = i;
}
}
rep2(i,1,n) rep2(j,1,m)
{
pref2[i][j] = pref2[i-1][j]+(i+l-1 <= n && j != 1 && pref[i+l-1][j]-pref[i-1][j]-pref[i+l-1][j-2]+pref[i-1][j-2] == 0);
pref3[i][j] = pref3[i][j-1]+(j+k-1 <= m && i != n && pref[i+1][j+k-1]-pref[i-1][j+k-1]-pref[i+1][j-1]+pref[i-1][j-1] == 0);
}
queue<pii> q;
q.push({y1,x1});
while(!q.empty())
{
pii t = q.front();
q.pop();
if(odw[t.ff][t.ss]) continue;
odw[t.ff][t.ss] = 1;
if(t.ss != 1 && pref2[t.ff][t.ss]-pref2[t.ff-l][t.ss] != 0) q.push({t.ff,t.ss-1});
if(t.ss != m && pref2[t.ff][t.ss+1]-pref2[t.ff-l][t.ss+1] != 0) q.push({t.ff,t.ss+1});
if(t.ff != 1 && pref3[t.ff-1][t.ss-k+1]-pref3[t.ff-1][t.ss] != 0) q.push({t.ff-1,t.ss});
if(t.ff != n && pref3[t.ff][t.ss-k+1]-pref3[t.ff][t.ss] != 0) q.push({t.ff+1,t.ss});
}
if(odw[y2][x2]) cout << "YES\n";
else cout << "NO\n";
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |