Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef pair<ll,ll>pll;
- typedef pair<ll,pair<ll,ll>>plll;
- #define F first
- #define S second
- ll const N=2e6;
- bool vis[1000][1000];
- bool f,ok=false;
- ll n,m,a,b,c,d,x,y;
- pair<ll,ll>s,e;
- char ara[1000][1000];
- void input()
- {
- char ch;
- ll i,j;
- cin>>n>>m;
- for(i=0; i<n; i++)
- {
- for(j=0; j<m;j++)
- {
- cin>>ara[i][j];
- ch=ara[i][j];
- if(ch=='X')
- vis[i][j]=true;
- }
- }
- cin>>a>>b>>x>>y;
- a--;b--,x--,y--;
- }
- ll flag=false;
- bool check(ll i,ll j)
- {
- if(i<0 || j<0 || i==n || j==m || (vis[i][j] && flag))
- return true;
- else return false;
- }
- void call(ll i,ll j)
- {
- if(i==x && j==y && vis[i][j] && flag)
- {
- ok=true;
- return;
- }
- if(check(i,j))return ;
- flag=true;
- vis[i][j]=true;
- call(i,j-1);
- call(i,j+1);
- call(i+1,j);
- call(i-1,j);
- }
- int main()
- {
- input();
- call(a,b);
- if(ok)cout<<"YES"<<endl;
- else cout<<"NO"<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement