This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// -------------------- Includes -------------------- //
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <array>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <iterator>
#include <numeric>
#include <complex>
#include <tuple>
#include <utility>
#include <cassert>
#include <assert.h>
#include <climits>
#include <limits.h>
#include <ctime>
#include <time.h>
#include <random>
#include <chrono>
#include <fstream>
using namespace std;
// -------------------- Typedefs -------------------- //
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
// -------------------- Defines -------------------- //
#define pr pair
#define mpr make_pair
#define ff first
#define ss second
#define mset multiset
#define mmap multimap
#define uset unordered_set
#define umap unordered_map
#define umset unordered_multiset
#define ummap unordered_multimap
#define pqueue priority_queue
#define sz(x) (int((x).size()))
#define len(x) (int((x).length()))
#define all(x) (x).begin(), (x).end()
#define clr(x) (x).clear()
#define ft front
#define bk back
#define pf push_front
#define pb push_back
#define popf pop_front
#define popb pop_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
// -------------------- Constants -------------------- //
const int MAX = int(1e9 + 5);
const ll MAXL = ll(1e18 + 5);
const ll MOD = ll(1e9 + 7);
const ll MOD2 = ll(998244353);
// -------------------- Functions -------------------- //
void fastio()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
return;
}
void precision(int x)
{
cout << fixed << setprecision(x);
return;
}
ll gcd0(ll a, ll b)
{
while (b) {
a %= b;
swap(a, b);
}
return a;
}
ll lcm0(ll a, ll b)
{
return a / gcd0(a, b) * b;
}
bool is_prime(ll a)
{
if (a == 1) return false;
for (ll i = 2; i * i <= a; i++) if (a % i == 0) return false;
return true;
}
bool is_square(ll a)
{
ll b = ll(sqrtl(ld(a)));
return (b * b == a);
}
bool is_cube(ll a)
{
ll b = ll(cbrtl(ld(a)));
return (b * b * b == a);
}
int digit_sum(ll a)
{
int sum = 0;
while (a) {
sum += int(a % 10);
a /= 10;
}
return sum;
}
ll binpow(ll a, int b)
{
ll ans = 1;
while (b) {
if (b & 1) ans *= a;
b >>= 1;
a *= a;
}
return ans;
}
ll binpow_mod(ll a, ll b, ll mod)
{
ll ans = 1;
while (b) {
if (b & 1) ans = (ans * a) % mod;
b >>= 1;
a = (a * a) % mod;
}
return ans;
}
ll factorial(int a)
{
ll ans = 1;
for (int i = 2; i <= a; i++) ans *= ll(i);
return ans;
}
ll factorial_mod(int a, ll mod)
{
ll ans = 1;
for (int i = 2; i <= a; i++) ans = (ans * ll(i)) % mod;
return ans;
}
// -------------------- Solution -------------------- //
const int N = 1505, M = 1505;
char a[N][M];
int px[N], py[M];
vector<pr<int, int>> g[N][M];
int n, m, k, l;
int xh, yh, xv, yv, tx, ty;
vector<int> vx[N], vy[M];
bool used[N][M];
void dfs(int x, int y)
{
if (a[x][y] == 'X') return;
used[x][y] = true;
for (int i = 0; i < sz(g[x][y]); i++) {
if (!used[g[x][y][i].ff][g[x][y][i].ss]) dfs(g[x][y][i].ff, g[x][y][i].ss);
}
return;
}
void solve()
{
int i, j;
cin >> m >> n >> k >> l;
cin >> yh >> xh >> yv >> xv;
for (i = 1; i <= n; i++) {
for (j = 1; j <= m; j++) {
cin >> a[i][j];
if (a[i][j] == '*') {
tx = i;
ty = j;
}
else if (a[i][j] == 'X') {
vx[i].pb(j);
vy[j].pb(i);
}
}
}
for (j = 1; j <= m; j++) sort(all(vy[j]));
int h;
int lx, rx, ly, ry;
int ul, ur;
for (i = 1; i <= n; i++) {
for (j = 1; j <= m; j++) {
if (a[i][j] == 'X') continue;
h = ub(all(vy[j]), i) - vy[j].begin();
if (h == sz(vy[j])) rx = n;
else rx = vy[j][h] - 1;
rx = min(rx, i + l - 1);
h--;
if (h < 0) lx = 1;
else lx = vy[j][h] + 1;
lx = max(lx, i - l + 1);
h = ub(all(vx[i]), j) - vx[i].begin();
if (h == sz(vx[i])) ry = m;
else ry = vx[i][h] - 1;
ry = min(ry, j + k - 1);
h--;
if (h < 0) ly = 1;
else ly = vx[i][h] + 1;
ly = max(ly, j - k + 1);
if (l > rx - lx + 1 || k > ry - ly + 1) continue;
if (i < n && rx >= i + 1 && a[i + 1][j] != 'X') {
h = ub(all(vx[i + 1]), j) - vx[i + 1].begin();
if (h == sz(vx[i + 1])) ur = m;
else ur = vx[i + 1][h] - 1;
ur = min(ur, ry);
h--;
if (h < 0) ul = 1;
else ul = vx[i + 1][h] + 1;
ul = max(ul, ly);
if (ur - ul + 1 >= l) {
g[i][j].pb(mpr(i + 1, j));
g[i + 1][j].pb(mpr(i, j));
}
}
if (j < m && ry >= j + 1 && a[i][j + 1] != 'X') {
h = ub(all(vy[j + 1]), i) - vy[j + 1].begin();
if (h == sz(vy[j + 1])) ur = n;
else ur = vy[j + 1][h] - 1;
ur = min(ur, rx);
h--;
if (h < 0) ul = 1;
else ul = vy[j + 1][h] + 1;
ul = max(ul, lx);
if (ur - ul + 1 >= k) {
g[i][j].pb(mpr(i, j + 1));
g[i][j + 1].pb(mpr(i, j));
}
}
}
}
dfs(xh + 1, yv + 1);
if (used[tx][ty]) cout << "YES\n";
else cout << "NO\n";
return;
}
void precalc()
{
return;
}
int main()
{
fastio();
precalc();
int tests = 1, tc;
//cin >> tests;
for (tc = 1; tc <= tests; tc++) {
solve();
}
return 0;
}
/*
# # # # # # # # # # # # # # # # #
# # # # # # # # # #
# # # # # # # # # # # # #
# # # # # # # # # # # #
# # # # # # # # # # # # # #
*/
# | 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... |