Submission #4032367


Source Code Expand

Copy
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
char s[1<<16];
int a[1<<16],b[1<<16];
int f[1<<16][2];
const int MOD=998244353;
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
inline int sub(int a,int b)
{a-=b;return a<0?a+MOD:a;}
inline int mul(int a,int b)
{return 1LL*a*b%MOD;}
inline int ksm(int a,int b)
{
    int ans=1;
    for(;b;b>>=1,a=mul(a,a))
        if(b&1)ans=mul(ans,a);
    return ans;
}
int fac[1<<16],ifac[1<<16];
#define C(x,y) mul(fac[x],mul(ifac[x-y],ifac[y]))
int Deal(int n,int m)
{
    f[0][0]=1;
    for(int j=1;j<=m;j++){
        f[0][j&1]=mul(fac[j],fac[j]);
        for(int i=1;i<=n;i++)
            f[i][j&1]=add(mul(f[i-1][j&1],i*j),mul(f[i][j&1^1],j*j));
            //fij=fi-1j*i*j+fij-1*j^2
    }
    int als=0;
    for(int i=0;i<=n;i++)
        als=add(als,mul(f[n-i][m&1],mul(mul(fac[i],fac[i]),mul(C(n,i),C(n+m,i)))));
    return als;
}
int main()
{
    scanf("%s",s+1);
    int s1=0,s2=0,n=strlen(s+1);
    for(int i=1;i<=n;i++)
        a[i]=s[i]-'0';
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
        b[i]=s[i]-'0';
    for(int i=1;i<=n;i++)
        if(a[i]+b[i]==2)++s1;
        else if(a[i])++s2;
    fac[0]=ifac[0]=1;
    for(int i=1;i<=10000;i++)
        fac[i]=mul(fac[i-1],i);
    ifac[n]=ksm(fac[n],MOD-2);
    for(int i=n-1;i;--i)
        ifac[i]=mul(ifac[i+1],i+1);
    printf("%d",Deal(s1,s2));
    return 0;
}

Submission Info

Submission Time
Task E - Shuffle and Swap
User luogu_bot2
Language C++ (GCC 5.4.1)
Score 1700
Code Size 1441 Byte
Status
Exec Time 80 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:42:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",s+1);
                    ^
./Main.cpp:46:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",s+1);
                    ^

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Partial 1200 / 1200 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt, subtask_1_29.txt, subtask_1_30.txt, subtask_1_31.txt, subtask_1_32.txt, subtask_1_33.txt, subtask_1_34.txt, subtask_1_35.txt, subtask_1_36.txt, subtask_1_37.txt, subtask_1_38.txt, subtask_1_39.txt, subtask_1_40.txt, subtask_1_41.txt, subtask_1_42.txt
All 500 / 500 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt, subtask_1_29.txt, subtask_1_30.txt, subtask_1_31.txt, subtask_1_32.txt, subtask_1_33.txt, subtask_1_34.txt, subtask_1_35.txt, subtask_1_36.txt, subtask_1_37.txt, subtask_1_38.txt, subtask_1_39.txt, subtask_1_40.txt, subtask_1_41.txt, subtask_1_42.txt, subtask_2_01.txt, subtask_2_02.txt, subtask_2_03.txt, subtask_2_04.txt, subtask_2_05.txt, subtask_2_06.txt, subtask_2_07.txt, subtask_2_08.txt, subtask_2_09.txt, subtask_2_10.txt, subtask_2_11.txt, subtask_2_12.txt, subtask_2_13.txt, subtask_2_14.txt, subtask_2_15.txt, subtask_2_16.txt, subtask_2_17.txt, subtask_2_18.txt, subtask_2_19.txt, subtask_2_20.txt, subtask_2_21.txt, subtask_2_22.txt, subtask_2_23.txt, subtask_2_24.txt, subtask_2_25.txt, subtask_2_26.txt, subtask_2_27.txt, subtask_2_28.txt, subtask_2_29.txt, subtask_2_30.txt, subtask_2_31.txt, subtask_2_32.txt, subtask_2_33.txt, subtask_2_34.txt, subtask_2_35.txt, subtask_2_36.txt, subtask_2_37.txt, subtask_2_38.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
sample_04.txt 1 ms 256 KB
subtask_1_01.txt 1 ms 256 KB
subtask_1_02.txt 1 ms 256 KB
subtask_1_03.txt 1 ms 256 KB
subtask_1_04.txt 1 ms 256 KB
subtask_1_05.txt 1 ms 256 KB
subtask_1_06.txt 1 ms 256 KB
subtask_1_07.txt 1 ms 256 KB
subtask_1_08.txt 1 ms 256 KB
subtask_1_09.txt 1 ms 256 KB
subtask_1_10.txt 1 ms 256 KB
subtask_1_11.txt 1 ms 256 KB
subtask_1_12.txt 1 ms 256 KB
subtask_1_13.txt 1 ms 256 KB
subtask_1_14.txt 1 ms 256 KB
subtask_1_15.txt 1 ms 256 KB
subtask_1_16.txt 1 ms 256 KB
subtask_1_17.txt 1 ms 256 KB
subtask_1_18.txt 1 ms 256 KB
subtask_1_19.txt 1 ms 256 KB
subtask_1_20.txt 1 ms 256 KB
subtask_1_21.txt 1 ms 256 KB
subtask_1_22.txt 1 ms 256 KB
subtask_1_23.txt 1 ms 256 KB
subtask_1_24.txt 1 ms 256 KB
subtask_1_25.txt 1 ms 256 KB
subtask_1_26.txt 1 ms 256 KB
subtask_1_27.txt 1 ms 256 KB
subtask_1_28.txt 1 ms 256 KB
subtask_1_29.txt 1 ms 256 KB
subtask_1_30.txt 1 ms 256 KB
subtask_1_31.txt 1 ms 256 KB
subtask_1_32.txt 1 ms 256 KB
subtask_1_33.txt 1 ms 256 KB
subtask_1_34.txt 1 ms 256 KB
subtask_1_35.txt 1 ms 256 KB
subtask_1_36.txt 1 ms 256 KB
subtask_1_37.txt 1 ms 256 KB
subtask_1_38.txt 1 ms 256 KB
subtask_1_39.txt 1 ms 256 KB
subtask_1_40.txt 1 ms 256 KB
subtask_1_41.txt 1 ms 256 KB
subtask_1_42.txt 1 ms 256 KB
subtask_2_01.txt 1 ms 384 KB
subtask_2_02.txt 1 ms 384 KB
subtask_2_03.txt 2 ms 384 KB
subtask_2_04.txt 60 ms 384 KB
subtask_2_05.txt 54 ms 384 KB
subtask_2_06.txt 2 ms 384 KB
subtask_2_07.txt 2 ms 512 KB
subtask_2_08.txt 2 ms 512 KB
subtask_2_09.txt 4 ms 512 KB
subtask_2_10.txt 71 ms 512 KB
subtask_2_11.txt 71 ms 512 KB
subtask_2_12.txt 71 ms 512 KB
subtask_2_13.txt 80 ms 512 KB
subtask_2_14.txt 80 ms 512 KB
subtask_2_15.txt 80 ms 512 KB
subtask_2_16.txt 71 ms 384 KB
subtask_2_17.txt 71 ms 384 KB
subtask_2_18.txt 71 ms 384 KB
subtask_2_19.txt 2 ms 384 KB
subtask_2_20.txt 1 ms 384 KB
subtask_2_21.txt 1 ms 384 KB
subtask_2_22.txt 30 ms 512 KB
subtask_2_23.txt 30 ms 512 KB
subtask_2_24.txt 30 ms 512 KB
subtask_2_25.txt 30 ms 512 KB
subtask_2_26.txt 42 ms 512 KB
subtask_2_27.txt 42 ms 512 KB
subtask_2_28.txt 3 ms 384 KB
subtask_2_29.txt 9 ms 384 KB
subtask_2_30.txt 35 ms 384 KB
subtask_2_31.txt 77 ms 512 KB
subtask_2_32.txt 78 ms 512 KB
subtask_2_33.txt 77 ms 384 KB
subtask_2_34.txt 77 ms 512 KB
subtask_2_35.txt 48 ms 512 KB
subtask_2_36.txt 48 ms 512 KB
subtask_2_37.txt 48 ms 512 KB
subtask_2_38.txt 48 ms 512 KB