标签:c11 style set one content memset panel 技术分享 文章
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2303 Accepted Submission(s): 1124
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int t,n,m,dp[18][18][1<<13]; int Map[105][105]; int main() { scanf("%d",&t); while(t--) { memset(dp,0,sizeof(dp)); scanf("%d %d",&n,&m); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) { scanf("%d",&Map[i][j]); } dp[0][m][0]=1; for(int i=1;i<=n;i++) { for(int k=0;k<(1<<m);k++) dp[i][0][k<<1]=dp[i-1][m][k]; for(int j=1;j<=m;j++) for(int sta=0;sta<(1<<(m+1));sta++) { int y=1<<j; int x=1<<(j-1); if(Map[i][j]) { if((sta&x)!=0&&(sta&y)!=0) { dp[i][j][sta]=dp[i][j-1][sta-x-y]; }else if((sta&x)==0&&(sta&y)==-0) { dp[i][j][sta]=dp[i][j-1][sta+x+y]; }else dp[i][j][sta]=dp[i][j-1][sta^x^y]+dp[i][j-1][sta]; }else { if((sta&x)==0&&(sta&y)==0) { dp[i][j][sta]=dp[i][j-1][sta]; }else dp[i][j][sta]=0; } } } cout<<dp[n][m][0]<<endl; } }
标签:c11 style set one content memset panel 技术分享 文章
原文地址:http://www.cnblogs.com/dancer16/p/7305970.html