2 条题解
-
-6陈俊宇 (陈俊宇) LV 10 @ 2022-12-18 10:16:52
#define jheswgf(a,b) a+b #define jhdswgf(a,b) a+b #define jhedsgswgf(a,b) a+b #define jheswgdgf(a,b) a+b #define jheswsfdggf(a,b) a+b #define jheswetergf(a,b) a+b #define jhesdgsdwgf(a,b) a+b #define dfgjheswgf(a,b) a+b #define sdfgfjheswgf(a,b) a+b #define sfgdjheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jdfdheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhgdfeswgf(a,b) a+b #define jhgdfsgegdswgf(a,b) a+b #define jhesswgf(a,b) a+b #define jhegdsgf(a,b) a+b #define jheswgf(a,b) a+b #define jhdeswgf(a,b) a+b #define gfd(a,b) a+b #define jheswgf(a,b) a+b #define jhefddsdfwgf(a,b) a+b #define jhefgsswgdssdgf(a,b) a+b #define jhesgsdsgswgf(a,b) a+b #define jhefsswgf(a,b) a+b #define jhseswgf(a,b) a+b #define jhsdeswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswsfgfsgsggf(a,b) a+b #define jhsgswgf(a,b) a+b #define jhegswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhesgsgsfdggwgf(a,b) a+b #define jsfdgdshesswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgsgdssfggf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jsgsdfgdheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhesdfgsdfsfwgf(a,b) a+b #define jhesfgsgsswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhesgffdgsswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhessgsdgswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhetreswgf(a,b) a+b #define jheetswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #include <iostream> #include <cstdio> #include <cstring> using namespace std; #define MAXN 411 #define ll long long bool vis[MAXN][17][7][7][7][7],f[MAXN][17][7][7][7][7];bool a[MAXN][17];long long n;const ll mx[]={0,0,1,0,-1,0,2,0,-2},my[]={0,1,0,-1,0,2,0,-2,0}; bool dfs(ll now,ll s,ll d1,ll d2,ll d3,ll d4){ ll x=(s-1)/4+1,y=(s-1)%4+1; if(x1&&y1)d1=0; else if(x1&&y3)d2=0; else if(x3&&y1)d3=0; else if(x3&&y3)d4=0; bool &cur=f[now][s][d1][d2][d3][d4]; if(vis[now][s][d1][d2][d3][d4])return cur; if(d1>6||d2>6||d3>6||d4>6)return cur=0; if(a[now][s]|a[now][s+1]|a[now][s+4]|a[now][s+5])return cur=0; vis[now][s][d1][d2][d3][d4]=1; if(now==n)return 1; for(ll i=0;i<9;++i) { ll vx=(s-1)/4+1+mx[i],vy=(s-1)%4+1+my[i]; if(vx>0&&vx<=3&&vy>0&&vy<=3) if(dfs(now+1,(vx-1)*4+vy,d1+1,d2+1,d3+1,d4+1))return cur=1; } return cur=0;} int main() { while(cin>>n) {
if(n==0)break; for(ll i=1;i<=n;++i) for(ll j=1;j<=16;++j)cin>>a[i][j]; memset(vis,0,sizeof vis);memset(f,0,sizeof f); if(dfs(1,6,1,1,1,1))puts("1"); else puts("0"); }
}
请放心该答案是正确的
-
-72021-8-7 21:15:25@
C++ :
#define jheswgf(a,b) a+b #define jhdswgf(a,b) a+b #define jhedsgswgf(a,b) a+b #define jheswgdgf(a,b) a+b #define jheswsfdggf(a,b) a+b #define jheswetergf(a,b) a+b #define jhesdgsdwgf(a,b) a+b #define dfgjheswgf(a,b) a+b #define sdfgfjheswgf(a,b) a+b #define sfgdjheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jdfdheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhgdfeswgf(a,b) a+b #define jhgdfsgegdswgf(a,b) a+b #define jhesswgf(a,b) a+b #define jhegdsgf(a,b) a+b #define jheswgf(a,b) a+b #define jhdeswgf(a,b) a+b #define gfd(a,b) a+b #define jheswgf(a,b) a+b #define jhefddsdfwgf(a,b) a+b #define jhefgsswgdssdgf(a,b) a+b #define jhesgsdsgswgf(a,b) a+b #define jhefsswgf(a,b) a+b #define jhseswgf(a,b) a+b #define jhsdeswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswsfgfsgsggf(a,b) a+b #define jhsgswgf(a,b) a+b #define jhegswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhesgsgsfdggwgf(a,b) a+b #define jsfdgdshesswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgsgdssfggf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jsgsdfgdheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhesdfgsdfsfwgf(a,b) a+b #define jhesfgsgsswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhesgffdgsswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhessgsdgswgf(a,b) a+b #define jheswgf(a,b) a+b #define jhetreswgf(a,b) a+b #define jheetswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #define jheswgf(a,b) a+b #include <iostream> #include <cstdio> #include <cstring> using namespace std; #define MAXN 411 #define ll long long bool vis[MAXN][17][7][7][7][7],f[MAXN][17][7][7][7][7];bool a[MAXN][17];long long n;const ll mx[]={0,0,1,0,-1,0,2,0,-2},my[]={0,1,0,-1,0,2,0,-2,0}; bool dfs(ll now,ll s,ll d1,ll d2,ll d3,ll d4){ ll x=(s-1)/4+1,y=(s-1)%4+1; if(x==1&&y==1)d1=0; else if(x==1&&y==3)d2=0; else if(x==3&&y==1)d3=0; else if(x==3&&y==3)d4=0; bool &cur=f[now][s][d1][d2][d3][d4]; if(vis[now][s][d1][d2][d3][d4])return cur; if(d1>6||d2>6||d3>6||d4>6)return cur=0; if(a[now][s]|a[now][s+1]|a[now][s+4]|a[now][s+5])return cur=0; vis[now][s][d1][d2][d3][d4]=1; if(now==n)return 1; for(ll i=0;i<9;++i) { ll vx=(s-1)/4+1+mx[i],vy=(s-1)%4+1+my[i]; if(vx>0&&vx<=3&&vy>0&&vy<=3) if(dfs(now+1,(vx-1)*4+vy,d1+1,d2+1,d3+1,d4+1))return cur=1; } return cur=0;} int main() { while(cin>>n) { if(n==0)break; for(ll i=1;i<=n;++i) for(ll j=1;j<=16;++j)cin>>a[i][j]; memset(vis,0,sizeof vis);memset(f,0,sizeof f); if(dfs(1,6,1,1,1,1))puts("1"); else puts("0"); } }
- 1
信息
- ID
- 102
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 2
- 标签
- 递交数
- 40
- 已通过
- 28
- 上传者