### aryan_cp's blog

By aryan_cp, history, 6 weeks ago,

Hello CodeForces can any body help me as to how to solve this problem? link : Problem Link I wanted help in Problem B — Horse Routes (when translated in English ) Thanks!

• +1

 » 6 weeks ago, # |   0 Auto comment: topic has been updated by aryan_cp (previous revision, new revision, compare).
 » 6 weeks ago, # |   0 Hey just do the usual bfs on the grid that should be good. I got that accepted check out the code for assistance there's nothing much to explain, it's quiet neat. AC_CODE#include #define ar array using namespace std; const int di[4]={1,-1,2,-2},dj[4]={2,2,-1,-1} ; int n, d[101][101]; bool e(int i,int j){ return(i>=0&&j>=0&&i> n ; memset(d,-1,sizeof(d)) ; queue>qu ; qu.push({0,0}) ;d[0][0]=0; while(qu.size()){ ar u = qu.front() ; qu.pop() ; for(int k=0;k<4;k++){ int ni = u[0]+ di[k],nj= u[1]+dj[k] ; if(!e(ni,nj)) continue ; qu.push({ni,nj}) ; d[ni][nj] = d[u[0]][u[1]]+1 ; } for(int k=0;k<4;k++){ int ni = u[0]+ di[k],nj= u[1]-dj[k] ; if(!e(ni,nj)) continue ; qu.push({ni,nj}) ; d[ni][nj] = d[u[0]][u[1]]+1 ; } } for(int i=0;i
•  » » 6 weeks ago, # ^ |   0 Thanks! For your help , Its my mistake I forgot to mention in the blog I wanted ython. Solution? I am new to competitive programming and I have no knowledge in BFS could you please suggest some links to study? Thanks!
•  » » » 6 weeks ago, # ^ |   0
•  » » » » 5 weeks ago, # ^ |   0 Thanks a lot!
 » 6 weeks ago, # |   0 use BFS