#include #include #include using namespace std; int row[] = {-1, 1, 2, 1, -1,-2}; int col[] = {-2,-2, 0, 2, 2, 0}; int print[100],jalan[200][200]; int x,y,dis,catat[200][200],n,ytujuan,xtujuan,xasal,yasal,step; bool visit[200][200]; queue > Q; void BFS (){ Q.push(make_pair(xasal,yasal)); memset(catat,0,sizeof(catat)); memset(visit,0,sizeof(visit)); while (!Q.empty()){ x = Q.front().first; y = Q.front().second; dis = catat[x][y]; Q.pop(); if (!visit[x][y]){ visit[x][y] = true; if (x==xtujuan && y == ytujuan){ step = dis; break; } for (int i =0; i<6;i++){ int y1 = y+row[i]; int x1 = x+col[i]; if (x1>=0 && y1>=0 && x1=0;i-- ){ if (jalan[x][y]==0){ print[i] = 0; x = x+col[3]; y = y+row[3]; } else if (jalan[x][y]==1){ print[i] = 1; x = x+col[4]; y = y+row[4]; } else if (jalan[x][y]==2){ print[i] = 2; x = x+col[5]; y = y+row[5]; } else if (jalan[x][y]==3){ print[i] = 3; x = x+col[0]; y = y+row[0]; } else if (jalan[x][y]==4){ print[i] = 4; x = x+col[1]; y = y+row[1]; } else if (jalan[x][y]==5){ print[i] = 5; x = x+col[2]; y = y+row[2]; } } printf("%d\n",step); for (int i = 0; i