#include<bits/stdc++.h> using namespace std; int n; bool po=false; int s[121][121]; int a[400][2]; int z=0,k,l,o,p; int dx[4]={0,-1,0,1}; int dy[4]={-1,0,1,0}; //void aaa() { // for (int i=0;i<z;i++) { // if (i!=0) cout<<"->"; // cout<<"("<<a[i][0]<<","<<a[i][1]<< ")"; // } // cout<<endl; //} bool dfs(int x,int y) { a[z][0]=x; a[z][1]=y; z++; if (x==o&&y== p) { po=true; return true; } s[x][y]=1; for (int i=0;i<4;i++) { int tx=x+dx[i]; int ty=y+dy[i]; if (tx>=1&&tx<=n&&ty>=1&&ty<=n&&s[tx][ty]==0) { if (dfs(tx,ty)){ return true; } } } z--; return false; } int main() { cin>>n; for (int i=1;i<=n;i++) { for (int j=1;j<=n;j++) { cin>>s[i][j]; } } cin>>k>>l>>o>>p; dfs(k,l); if(po){ cout<<"YES"; }else{ cout<<"NO"; } return 0; } /************************************************************** Problem: 1430 User: zhengzihao Language: C++ Result: Wrong Answer ****************************************************************/