#include using namespace std; #define gin getchar_unlocked #define MAX 40005 #define pb push_back #define mp make_pair #define initial 1 #define waiting 2 #define visited 3 vector< pair > graph[MAX]; int state[MAX]; int parent[MAX]; int parentP[MAX]; int dist[MAX]; int x; queue queuee; void in(int &n) { n = 0; int cr = gin(); int s = 1; while (cr < '0' || cr > '9') { if (cr == '-') s = -1; cr = gin(); } while (cr >= '0' && cr <= '9') n = (n << 3) + (n << 1) + cr - '0', cr = gin(); n = n * s; } void BFS(int v) { int i; queuee.push(v); state[v] = waiting; //dist[v]=0; while (!queuee.empty()) { v = queuee.front(); queuee.pop(); //printf("%d",v); state[v] = visited; for (i = 0; i < graph[v].size(); i++) { int xq = graph[v][i].first; if (state[xq] == initial) { queuee.push(xq); state[xq] = waiting; parent[xq] = v; parentP[xq] = graph[v][i].second; } } } } int main() { ios_base::sync_with_stdio(false); int n, xs, ys, xe, ye; int ul, ur, r, lr, ll, l, temp; int tx, ty; in(n); in(xs); in(ys); in(xe); in(ye); memset(state, 1, sizeof(state)); memset(parent, -1, sizeof(parent)); memset(parentP, -1, sizeof(parentP)); memset(dist, 0, sizeof(dist)); x = n * n; for(int i=0;i= 0 && ty >= 0 && tx < n && ty < n) { ul=tx * n + ty; graph[i].pb(mp(tx * n + ty,0)); //graph[ul].pb(mp(i,0)); } tx = xx - 2; ty = yy + 1; if (tx >= 0 && ty >= 0 && tx < n && ty < n) { ul=tx * n + ty; graph[i].pb(mp(tx * n + ty,1)); //graph[ul].pb(mp(i,1)); } tx = xx; ty = yy + 2; if (tx >= 0 && ty >= 0 && tx < n && ty < n) { ul=tx * n + ty; graph[i].pb(mp(tx * n + ty,2)); //graph[ul].pb(mp(i,2)); } tx = xx + 2; ty = yy + 1; if (tx >= 0 && ty >= 0 && tx < n && ty < n) { ul=tx * n + ty; graph[i].pb(mp(tx * n + ty,3)); //graph[ul].pb(mp(i,3)); } tx = xx + 2; ty = yy - 1; if (tx >= 0 && ty >= 0 && tx < n && ty < n) { ul=tx * n + ty; graph[i].pb(mp(tx * n + ty,4)); //graph[ul].pb(mp(i,4)); } tx = xx; ty = yy - 2; if (tx >= 0 && ty >= 0 && tx < n && ty < n) { ul=tx * n + ty; graph[i].pb(mp(tx * n + ty,5)); //graph[ul].pb(mp(i,5)); } } /*for (int i = 0; i < x; i++) { cout< paths; int ccc = 0; while (ttemp != start) { //cout<0;i--) cout<