标签:class 表示 art i++ image uid strong 同时存在 row
#include<cstdio> #include<iostream> using namespace std; const int N=55,M=206; int dx[8]={-1,-1,0,1,1,1,0,-1}; int dy[8]={0,-1,-1,-1,0,1,1,1}; int ans=0,tot=0; bool f[206],vis[406][406],used[206][406][406][8]; void dfs(int t, int x, int y, int d) { if(t>tot) return; if(used[t][x][y][d]) return; //记忆化 used[t][x][y][d]=true; if(!vis[x][y]) { ans++; vis[x][y]=true; } if(f[t]) //转向45度 { dfs(t+1,x+dx[(d+1)%8],y+dy[(d+1)%8],(d+1)%8); dfs(t+1,x+dx[(d+7)%8],y+dy[(d+7)%8],(d+7)%8); } else dfs(t+1,x+dx[d],y+dy[d],d); } int main() { int n,t; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&t); tot+=t; f[tot]=true; } dfs(1,tot,tot,0); printf("%d",ans); }
标签:class 表示 art i++ image uid strong 同时存在 row
原文地址:http://www.cnblogs.com/farway17/p/6936950.html