// // KnightLChessboard.cpp // HR // // Created by Admin on 10/02/2017. // Copyright © 2017 Jose. All rights reserved. // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define pb push_back #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define sz size() #define rep(i,m) for(int i=0;i<(int)(m);i++) #define rep2(i,n,m) for(int i=n;i<(int)(m);i++) #define For(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();++it) #define mem(a,b) memset(a,b,sizeof(a)) #define mp make_pair #define F first #define S second #define pb push_back #define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i) #define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr) #define pw(x) (1LL<<(x)) #define DBGV(vari) cout << #vari<< " = "<< (vari) < pii; typedef vector vpii; typedef vector vs; typedef vector vi; typedef vector vd; typedef vector > vvi; typedef long long ll; typedef long double ld; typedef vector vll; typedef pair pdd; typedef pair pll; typedef vector vpll; typedef vector vvpll; //const int oo = (int) 1e9; const double PI = 2 * acos(0); //const double eps = 1e-9; const ll inf=1e10; int n; struct move{ int a,x,y; move(int a, int x, int y){ this->a=a; this->x=x; this->y=y; } } ; typedef struct move move; bool operator<(const struct move &a, const struct move &b) { return a.a q; unordered_set vis; struct move* sta= new struct move(0,0,0); q.push(sta); vis.insert(0); while (!q.empty()) { struct move* st=q.top(); q.pop(); int a=st->a, x=st->x, y=st->y; if(j==3){ //DBGV(a) DBGV(x) DBGV(y) cout<=0 && y+dy=0){ struct move* nm= new struct move(a-1,x+dx,y+dy); //DBGV(a) DBGV(x+dx) DBGV(y+dy) q.push(nm); vis.insert(n*(x+dx)+y+dy); } } } return -1; //if(p%i!=0 || p%j!=0) return -1; //return p/i; } int solve2(int i, int j){ // i<=j unordered_set vis; int p=n-1; priority_queue q; struct move sta= *(new struct move(0,0,0)); vis.insert(0); q.push(sta); while (!q.empty()) { struct move st=q.top(); q.pop(); int a=st.a, x=st.x, y=st.y; if(j==3) { //DBGV(a) DBGV(x) DBGV(y) } if(x==p && y==p) return -a; for(int k=0;k<8;k++){ int dx=k<4?i:j, dy=i+j-dx; if(k%2) dx=-dx; if(k/2%2) dy=-dy; if(vis.find((x+dx)*n+y+dy)==vis.end() && x+dx=0 && y+dy=0){ struct move nm= *new struct move(a-1,x+dx,y+dy); q.push(nm); vis.insert(n*(x+dx)+y+dy); } } } return -1; } int main(){ cin>>n; for(int i=1;i