#include <bits/stdc++.h>
using namespace std;
#define State pair<pair<int,int>,pair<int,int>>
#define xh first.first
#define yh first.second
#define xv second.first
#define yv second.second
const int N=360;
const int M=360; // try setting it to 181
char grid[N][N];
int pre_row[N][N],pre_col[N][N];
bitset<N> seen[N][M][M];
int k,l,h,w;
int get_row(int x,int y)
{
return pre_row[x][y+k]-pre_row[x][y];
}
int get_col(int x,int y)
{
return pre_col[x+l][y]-pre_col[x][y];
}
// set<State> valid;
bool Valid(State& cur)
{
return (min({cur.xh,cur.yh,cur.xv,cur.yv})>=0 and max(cur.xh,cur.xv)<h and max(cur.yh,cur.yv)<w and (cur.yv-cur.yh)>=0 and (cur.xh-cur.xv)>=0 and seen[cur.xh][cur.yv-cur.yh][cur.xh-cur.xv][cur.yv]);
}
State make_state(int x,int y,int x1,int y1)
{
State tp;
tp.xh=x;
tp.yh=y;
tp.xv=x1;
tp.yv=y1;
return tp;
}
queue<State> q;
void mark(State cur)
{
q.push(cur);
seen[cur.xh][cur.yv-cur.yh][cur.xh-cur.xv][cur.yv]=0;
}
// let change state to (x,y,U,L)
// U <=
int main()
{
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
cin>>w>>h>>k>>l;
int xh1,yh1,xv1,yv1;
cin>>xh1>>yh1>>xv1>>yv1;
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
{
cin>>grid[i][j];
pre_row[i][j+1]=pre_row[i][j]+(grid[i][j]=='X');
pre_col[i+1][j]=pre_col[i][j]+(grid[i][j]=='X');
}
}
for(int U=0;U<l;U++)
{
int D=l-1-U;
if(D<0)break;
for(int L=0;L<k;L++)
{
int R=k-1-L;
if(R<0)break;
for(int i=U;(i+D)<h;i++)
{
for(int j=L;(j+R)<w;j++)
{
if(get_row(i,j-L)==0 and get_col(i-U,j)==0)
{
// cout<<"Valid "<<i<<' '<<j-L<<' '<<i-U<<' '<<j<<endl;;
// H *
// seen[i][j-L][i-U][j]=1;
seen[i][L][U][j]=1;
// change to [i][L][U][j]
}
}
}
}
}
vector<pair<int,int>> dir={{-1,0},{0,-1},{0,1},{1,0}};
mark(make_state(yh1,xh1,yv1,xv1));
while(q.size()>0)
{
auto it=q.front();
q.pop();
// cout<<"At "<<it.xh<<' '<<it.yv-it.yh<<' '<<it.xh-it.xv<<' '<<it.yv<<endl;
if(grid[it.xh][it.yv]=='*')
{
cout<<"YES"<<'\n';
return 0;
}
// it.yh=it.yv-it.yh;
// it.xv=it.xh-it.xv;
for(auto&[dx,dy]:dir)
{
it.xh+=dx;
it.yh+=dy;
if(Valid(it))
mark(it);
it.xh-=dx;
it.yh-=dy;
}
for(auto&[dx,dy]:dir)
{
it.xv+=dx;
it.yv+=dy;
if(Valid(it))
mark(it);
it.xv-=dx;
it.yv-=dy;
}
}
cout<<"NO"<<'\n';
}
Compilation message (stderr)
/tmp/ccRFOOmy.o: in function `get_row(int, int)':
Main.cpp:(.text+0x10): relocation truncated to fit: R_X86_64_PC32 against symbol `pre_row' defined in .bss section in /tmp/ccRFOOmy.o
/tmp/ccRFOOmy.o: in function `get_col(int, int)':
Main.cpp:(.text+0x40): relocation truncated to fit: R_X86_64_PC32 against symbol `pre_col' defined in .bss section in /tmp/ccRFOOmy.o
/tmp/ccRFOOmy.o: in function `main':
Main.cpp:(.text.startup+0x11): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
Main.cpp:(.text.startup+0x43): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
Main.cpp:(.text.startup+0x4e): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
Main.cpp:(.text.startup+0xda): relocation truncated to fit: R_X86_64_PC32 against symbol `grid' defined in .bss section in /tmp/ccRFOOmy.o
Main.cpp:(.text.startup+0xe1): relocation truncated to fit: R_X86_64_PC32 against symbol `pre_col' defined in .bss section in /tmp/ccRFOOmy.o
Main.cpp:(.text.startup+0x105): relocation truncated to fit: R_X86_64_PC32 against symbol `pre_row' defined in .bss section in /tmp/ccRFOOmy.o
Main.cpp:(.text.startup+0x1a8): relocation truncated to fit: R_X86_64_PC32 against symbol `pre_row' defined in .bss section in /tmp/ccRFOOmy.o
Main.cpp:(.text.startup+0x1b8): relocation truncated to fit: R_X86_64_PC32 against symbol `pre_col' defined in .bss section in /tmp/ccRFOOmy.o
Main.cpp:(.text.startup+0x4b7): additional relocation overflows omitted from the output
/usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1c): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x1c6): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x260): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2e2): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x353): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x541): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5e5): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x670): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x6e9): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
collect2: error: ld returned 1 exit status