Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
终于搞过。。。。#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: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator