Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 终于搞过。。。。

Posted by team162 at 2011-01-03 21:17:56 on Problem 3254
```#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
using namespace std;
int dp[14][4100];
int map[14];
int state[4100];
const int mod=100000000;
int main()
{
int n,m;
cin>>m>>n;
memset(dp,0,sizeof(dp));
for(int i=1;i<=m;++i)
{
map[i]=0;
int k;
for(int j=0;j<n;++j)
{
cin>>k;
map[i]|=(k<<j);
}
}
int s=0;
for(int i=0;i<(1<<n);++i)
{
int j=0;
for(j=0;j<n-1;++j)
if((i&(1<<j))&&(i&(1<<(j+1))))
break;
if(j==n-1)
state[s++]=i;
}

for(int i=0;i<s;++i)
if(!(~map[1]&state[i]))
dp[1][state[i]]=1;
for(int i=2;i<=m;++i)
{
for(int j=0;j<s;++j)
{
if((~map[i])&state[j])
continue;
for(int k=0;k<s;++k)
{
if(!((state[k]&state[j])||((~map[i-1])&state[k])))
{
dp[i][state[j]]+=dp[i-1][state[k]];
dp[i][state[j]]%=mod;
}
}
}
}
int res=0;
for(int i=0;i<(1<<n);++i)
{
res+=dp[m][i];
res%=mod;
}
cout<<res<<endl;
return 0;

}```

Followed by: