#include #include #include #include #include using namespace std; int n,ox,oy,m[50][50]; struct per { int x,y; }a[50]; set< vector >V; pairh[50]; long long ras,cate; const int dx[4]={0,1,0,-1}; const int dy[4]={1,0,-1,0}; void bck(int k,int i,int j) { if(k==n-1) { int minx=ox; int miny=oy; for(int i=0;ia[i].x)minx=a[i].x; if(miny>a[i].y)miny=a[i].y; } for(int i=0;icurr; for(int i=0;i > :: iterator it = V.find (curr); if(it==V.end()) { ras++; V.insert(curr); } return ; } int nx,ny; for(int o=0;o<4;o++) { nx=i+dx[o]; ny=j+dy[o]; if(m[nx][ny]==0) { m[nx][ny]=1; a[k+1].x=nx; a[k+1].y=ny; bck(k+1,nx,ny); m[nx][ny]=0; } } } int main() { //freopen("input","r",stdin); //freopen("output","w",stdout); scanf("%d",&n); ox=15; oy=15; a[0].x=ox; a[0].y=oy; m[ox][oy]=1; bck(0,ox,oy); printf("%lld",ras); return 0; } /*#include #include #include using namespace std; int n,m[50][50]; long long ras,cate; const int dx[4]={0,1,0,-1}; const int dy[4]={1,0,-1,0}; void bck(int k,int i,int j,int mx,int my) { if(k==n-1) { ras++; return ; } int nx,ny; int xmax,ymax; for(int o=0;o<4;o++) { nx=i+dx[o]; ny=j+dy[o]; if(m[nx][ny]==0) { m[nx][ny]=1; xmax=mx; ymax=my; if(xmax>nx) { xmax=nx; ymax=ny; } else if(xmax==nx&&ymax