QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#358575#8174. Set ConstructionSolitaryDream#WA 0ms9832kbC++172.2kb2024-03-19 21:11:222024-03-19 21:11:22

Judging History

你现在查看的是最新测评结果

  • [2024-03-19 21:11:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:9832kb
  • [2024-03-19 21:11:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long 

const int N=411,P=998244353;

int n,a[N];

int e[N][N],f[N][N],g[N][N],C[N][N],h[N],l[N],t[N][N],pw[N][N];

int qpow(int a,int b)
{
    int ret=1;
    while(b)
    {
        if(b&1)
            ret=ret*a%P;
        b>>=1;
        a=a*a%P;
    }
    return ret;
}

signed main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        pw[i][0]=1;
        for(int j=1;j<=n;j++)
            pw[i][j]=pw[i][j-1]*i%P;
    }
    C[0][0]=1;
    e[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        C[i][0]=1;
        e[i][0]=1;
        for(int j=1;j<=i;j++)
        {
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%P;
            e[i][j]=(e[i-1][j]+e[i-1][j-1]*a[i])%P;
        }
    }
    for(int i=1;i<=n;i++)
        e[n][i]=e[n][i]*qpow(C[n][i],P-2)%P;
    f[0][0]=1;
    h[0]=1;
    g[0][0]=1;
    t[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        l[i]=qpow(2,i*(i-1)/2);
        for(int j=1;j<i;j++)
            l[i]=(l[i]-C[i-1][j-1]*l[j]%P*qpow(2,(i-j)*(i-j-1)/2)%P+P)%P;
        for(int j=1;j<=i;j++)
        {
            for(int k=1;k<=i;k++)
                t[i][j]=(t[i][j]+C[i-1][k-1]*k%P*t[i-k][j-1]%P*l[k])%P;
        }
        h[i]=l[i];
        for(int j=1;j<i;j++)
            for(int k=1;k<=i-j;k++)
                h[i]=(h[i]-C[i-1][j-1]*t[i-j][k]%P*h[j]%P*pw[j][k])%P;
        h[i]=(h[i]%P+P)%P;

        //{
        // for (int j = 1; j <= i; ++j) 
        //     for (int k = 1; k <= j; ++k) t[i][j] = (t[i][j] + C[i - 1][j - 1] * t[i - j][k - 1] % P * (j + 1) % P * l[j]) % P;
        // h[i] = l[i];
        // for (int j = 1; j < i; ++j) 
        //     for (int k = 1; k <= i - j; ++k) 
        //         h[i] = (h[i] - h[j] * C[i - 1][j - 1] % P * t[i - j][k] % P * pw[j][k]) % P;
        // h[i]=(h[i]%P+P)%P;
        //}
        
        for(int j=1;j<=i;j++)
        {
            for(int k=1;k<=i;k++)
                f[i][j]=(f[i][j]+C[i-1][k-1]*h[k]%P*k%P*f[i-k][j-1]%P)%P;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int ways=i==1?1:pw[n][i-2];
        ans=(ans+e[n][i]*f[n][i]%P*ways)%P;
    }
    cout<<ans<<"\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 9832kb

input:

3
3 5
4 8
60 2

output:

192

result:

wrong answer Integer element [index=1] equals to 192, violates the range [0, 7]