标签:style io ar color sp for on bs 代码
#include <cstdio> #include <cstring> #include <algorithm> #include <vector> using namespace std; #define mod 100000000 int dp[13][1<<13]; vector<int> mp[20]; int n,m; int a,b[20]; bool cheak2(int x) { return !(x & (x >> 1)); } bool cheak1(int a, int b) { return !(a & b); } int main() { while(scanf("%d%d",&n,&m)==2) { memset(dp,0,sizeof(dp)); for(int i=0; i<n; i++) { b[i]=0; for(int j=0; j<m; j++) { scanf("%d",&a); if(a) b[i]=b[i]|(1<<j); } } for(int i=0;i<n;i++){ // printf("%d\n",b[i]); mp[i].clear(); for(int j=0;j<(1<<m);j++) if(((b[i]|j)==b[i])&&cheak2(j)) mp[i].push_back(j); } /* for(int i=0;i<n;i++){ for(int j=0;j<mp[i].size();j++) { printf("%d ",mp[i][j]); } puts(""); }*/ for(int i=0; i<mp[0].size(); i++) { dp[0][mp[0][i]]=1; } for(int i=1; i<n; i++) for(int j=0; j<mp[i].size(); j++) { for(int k=0;k<mp[i-1].size();k++){ if(cheak1(mp[i][j],mp[i-1][k])) dp[i][mp[i][j]]=(dp[i][mp[i][j]]+dp[i-1][mp[i-1][k]])%mod; } } int ans=0; for(int i=0;i<mp[n-1].size();i++){ ans=(dp[n-1][mp[n-1][i]]+ans)%mod; } printf("%d\n",ans); } } /* 10 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 */
poj 3254 --- Corn-Fields(状态压缩)
标签:style io ar color sp for on bs 代码
原文地址:http://blog.csdn.net/u013076044/article/details/41480203