Submission #14650

# Submission time Handle Problem Language Result Execution time Memory
14650 2015-05-24T09:49:39 Z dohyun0324 선다형 시험 (TOKI14_multiple) C++
16 / 100
11 ms 48592 KB
#include<stdio.h>
int w2,n,p,q,w,a[2010],b[2010],ch[2010][6],w1,w0,same[2010],dif[2010],cnt2[2010];
long long t,dap,cnt,d0[2010],d1[2010],d[2010],dif0[2010],dif1[2010],dp[2010][2010];
int comb[2010][2010];
char x2,c[7];
int main()
{
    int i,j,x;
    scanf("%d %d %d",&n,&p,&q);
    for(i=1;i<=n;i++){
        scanf(" %c",&x2);
        a[i]=x2-'a'+1;
    }
    for(i=1;i<=n;i++){
        scanf(" %c",&x2);
        b[i]=x2-'a'+1;
    }
    for(i=1;i<=n;i++){
        scanf("%s",&c);
        for(j=0;j<=4;j++){
            if(c[j]!='.') ch[i][j+1]=1, cnt2[i]++;
        }
    }
    for(i=1;i<=n;i++){
        if(a[i]==b[i]) same[++w]=i;
        else{
            if(ch[i][b[i]]) dif1[++w1]=cnt2[i]-2;
            else dif0[++w0]=cnt2[i]-1;
        }
    }
    dp[0][0]=1;
    for(i=1;i<=w;i++){
        x=same[i]; cnt=0;
        for(j=1;j<=5;j++){
            if(ch[x][j]) cnt++;
        }
        if(ch[x][a[x]]) dp[i][0]=dp[i-1][0]*(cnt-1);
        else dp[i][0]=dp[i-1][0]*cnt;
        for(j=1;j<=i;j++){
            if(ch[x][a[x]]) dp[i][j]=dp[i-1][j-1]+dp[i-1][j]*(cnt-1);
            else dp[i][j]=dp[i-1][j]*cnt;
            dp[i][j]%=1000000007;
        }
    }
    for(i=0;i<=w;i++) d[i]=dp[w][i];
    for(i=1;i<=w0;i++)
    {
        dp[i][0]=dp[i-1][0]*dif0[i]; dp[i][0]%=1000000007;
        for(j=1;j<=i;j++)
        {
            dp[i][j]=dp[i-1][j]*dif0[i]+dp[i-1][j-1];
            dp[i][j]%=1000000007;
        }
    }
    for(i=0;i<=w0;i++) d0[i]=dp[w0][i];
    for(i=1;i<=w1;i++)
    {
        dp[i][0]=dp[i-1][0]*dif1[i]; dp[i][0]%=1000000007;
        for(j=1;j<=i;j++)
        {
            dp[i][j]=dp[i-1][j]*dif1[i]+dp[i-1][j-1];
            dp[i][j]%=1000000007;
        }
    }
    for(i=0;i<=w1;i++) d1[i]=dp[w1][i];
    comb[0][0]=1;
    for(i=1;i<=w1;i++)
    {
        comb[i][0]=1;
        for(j=1;j<=i;j++)
        {
            comb[i][j]=comb[i-1][j]+comb[i-1][j-1];
            comb[i][j]%=1000000007;
        }
    }
    for(i=0;i<=p;i++)
    {
        for(j=0;j<=p-i;j++)
        {
            if(p+q-i*2-j>=0 && p-i-j>=0)
            {
                t=d0[j]; t%=1000000007;
                t*=d1[p+q-i*2-j]; t%=1000000007;
                t*=(long long)comb[p+q-i*2-j][p-j-i]*d[i]; t%=1000000007;
            }
            dap+=t;
            dap%=1000000007;
        }
    }
    printf("%lld",dap);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 48592 KB Output is correct
2 Correct 0 ms 48592 KB Output is correct
3 Correct 0 ms 48592 KB Output is correct
4 Correct 0 ms 48592 KB Output is correct
5 Correct 0 ms 48592 KB Output is correct
6 Correct 0 ms 48592 KB Output is correct
7 Correct 0 ms 48592 KB Output is correct
8 Incorrect 0 ms 48592 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 48592 KB Output is correct
2 Correct 0 ms 48592 KB Output is correct
3 Correct 2 ms 48592 KB Output is correct
4 Correct 11 ms 48592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 48592 KB Output isn't correct
2 Halted 0 ms 0 KB -