#include #include #include #include #include #include using namespace std; int n,sx,sy,ex,ey; bool vis[500][500]; int dis[500][500]; int kaise[500][500]; pair kahan[500][500]; bool check(int x,int y) { if(x>=0 && x=0 && y> q; q.push({x,y}); vis[x][y]=1; dis[x][y]=0; kaise[x][y]=-1; kahan[x][y]=make_pair(-1,-1); while(q.empty()==0) { pair temp=q.front(); q.pop(); int x1=temp.first;int y1=temp.second; // if(x1==ex && y1==ey) break; int cdis=dis[x1][y1]; if(check(x1-2,y1-1)) { vis[x1-2][y1-1]=1; dis[x1-2][y1-1]=1+cdis; kaise[x1-2][y1-1]=1; q.push({x1-2,y1-1}); kahan[x1-2][y1-1]=make_pair(x1,y1); } if(check(x1-2,y1+1)) { vis[x1-2][y1+1]=1; dis[x1-2][y1+1]=1+cdis; kaise[x1-2][y1+1]=2; q.push({x1-2,y1+1}); kahan[x1-2][y1+1]=make_pair(x1,y1); } if(check(x1,y1+2)) { vis[x1][y1+2]=1; dis[x1][y1+2]=1+cdis; kaise[x1][y1+2]=3; q.push({x1,y1+2}); kahan[x1][y1+2]=make_pair(x1,y1); } if(check(x1+2,y1+1)) { vis[x1+2][y1+1]=1; dis[x1+2][y1+1]=1+cdis; kaise[x1+2][y1+1]=4; q.push({x1+2,y1+1}); kahan[x1+2][y1+1]=make_pair(x1,y1); } if(check(x1+2,y1-1)) { vis[x1+2][y1-1]=1; dis[x1+2][y1-1]=1+cdis; kaise[x1+2][y1-1]=5; q.push({x1+2,y1-1}); kahan[x1+2][y1-1]=make_pair(x1,y1); } if(check(x1,y1-2)) { vis[x1][y1-2]=1; dis[x1][y1-2]=1+cdis; kaise[x1][y1-2]=6; q.push({x1,y1-2}); kahan[x1][y1-2]=make_pair(x1,y1); } } /* for(int i=0;i ans; naya1=ex;naya2=ey; while(1) { int where=kaise[naya1][naya2]; // cout<=0;i--) cout<>n>>sx>>sy>>ex>>ey; if(sx==ex && sy==ey) { cout<<"0"<