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

这题什么情况呀,我用滚动数组就是wa的,尼玛

Posted by acm79 at 2013-05-17 17:41:40 on Problem 3254
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <queue>

using namespace std;

const int maxn=12+5;
const int maxm=12+5;

int n,m,tot;
int state[380],stanum[380];
int in[maxm];
bool flg[maxn];
//char s[maxn][maxm];

void dfs(int cur,int st,int count)
{
    if(cur==n)
    {
        state[tot]=st;
        stanum[tot++]=count;
        return;
    }
    flg[cur+1]=0;
    dfs(cur+1,st<<1,count);
    if(flg[cur]==0)
    {
        flg[cur+1]=1;
        dfs(cur+1,st<<1|1,count+1);
    }
}

void init()
{
    tot=0;
    memset(flg,0,sizeof(flg));
    dfs(0,0,0);
}

void data_in()
{
    int tmp;
    for(int i=1;i<=m;i++)
    {
        in[i]=0;
        for(int j=1;j<=n;j++)
        {
            scanf("%d",&tmp);
            in[i]=in[i]*2+tmp^1;
        }
    }
}

int dp[2][380];
void DP()
{
    memset(dp,0,sizeof(dp));
    for(int i=0;i<tot;i++)
    {
        if(in[1]&state[i]) continue;
        dp[1][i]=1;
    }
    int now=1;
    for(int i=2;i<=m;i++)
    {
        now^=1;
        for(int j=0;j<tot;j++)
        {
            if(in[i]&state[j]) continue;
            else for(int k=0;k<tot;k++)
            {
                if(state[j]&state[k]) continue;
//                else dp[i][j]=(dp[i][j]+dp[i-1][k])%100000000;
                else dp[now][j]=(dp[now][j]+dp[now^1][k])%100000000;
            }
        }
    }
    int ans=0;
    for(int i=0;i<tot;i++)
//        ans=(ans+dp[m][i])%100000000;
        ans=(ans+dp[now][i])%100000000;
    printf("%d\n",ans);
}

int main()
{
    while(~scanf("%d %d",&m,&n))
    {
        init();
        data_in();
        DP();
    }
    return 0;
}
是哪里出问题了吗?

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator