QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#783244#9566. TopologyDarwin_ArnoldCompile Error//C++202.1kb2024-11-26 02:58:222024-11-26 02:58:23

Judging History

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

  • [2024-11-26 02:58:23]
  • 评测
  • [2024-11-26 02:58:22]
  • 提交

answer

#include<bits/stdc++.h>
#dedine ll long long
using namespace std;
const int N=5010;
ll mod=998244353;
int n;
vector<int>G[N];
ll L[N];
int sz[N];
int p[N];
ll f[N];
ll g[N][N];
ll dp[N][N];
ll S[N][N];
ll ans[N];
ll fast_pow(ll a,ll m)
{
    ll base=a;
    ll res=1;
    while(m)
    {
        if(m&1)res=(int)((res*1ll*base)%mod);
        base=((base*1ll*base)%mod;
        m>>=1;
    }
    return res;
}
ll mod_inverse(ll x)
{
    return (ll)(fast_pow(x,mod-2));
}
ll C(ll x,ll y)
{
    return (ll)((((L[x]*1ll*mod_inverse(L[y]))%mod)*1ll*mod_inverse(L[x-y]))%mod);
}
void dfs_1(int u,int fa)
{
    int temp=L[sz[u]-1];
    for(int i=0;i<G[u].size();i++)
    {
        int v=G[u][i];
        dfs_1(v,u);
        temp=(ll)((temp*1ll*f[v])%mod);
        temp=(ll)((temp*1ll*mod_inverse(L[sz[v]]))%mod);
        //printf("%d\n",temp);
    }
    f[u]=temp;
    for(int i=0;i<G[u].size();i++)
    {
        int v=G[u][i];
        g[u][v]=(ll)((((f[u]*1ll*mod_inverse(f[v]))%mod)*mod_inverse(C(sz[u]-1,sz[v])))%mod);
    }
}
void dfs_2(int u,int fa)
{
    if(u!=1)
    {
        for(int i=1;i<=n;i++)
        {
            S[fa][i]=(ll)(((S[fa][i-1]*1ll+(dp[fa][i]*1ll*C(n-sz[u]-i,sz[fa]-sz[u]-1))%mod))%mod);
            dp[u][i]=(ll)(g[fa][u]*1ll*S[fa][i-1])%mod;
        }
    }
    for(int i=0;i<G[u].size();i++)
    {
        int v=G[u][i];
        dfs_2(v,u);
    }
}
int main()
{
    scanf("%lld",&n);
    L[0]=1;
    for(int i=1;i<=n;i++)L[i]=(int)((i*1ll*L[i-1])%mod);
    for(int i=2;i<=n;i++)
    {
        int x;
        scanf("%lld",&x);
        p[i]=x;
        G[x].push_back(i);
    }
    for(int i=1;i<=n;i++)sz[i]=1;
    for(int i=n;i>=2;i--)sz[p[i]]+=sz[i];
    dp[1][1]=1;
    dfs_1(1,0);
    dfs_2(1,0);
    for(int i=1;i<=n;i++)
    {
        ans[i]=(ll)((((dp[i][i]*1ll*f[i])%mod)*1ll*C(n-i,sz[i]-1))%mod);
    }
    /*
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            printf("%d ",g[i][j]);
        }
        printf("\n");
    }
    */
    for(int i=1;i<=n;i++)
    {
        printf("%lld ",ans[i]);
    }
    return 0;
}

Details

answer.code:2:2: error: invalid preprocessing directive #dedine; did you mean #define?
    2 | #dedine ll long long
      |  ^~~~~~
      |  define
answer.code:5:1: error: ‘ll’ does not name a type
    5 | ll mod=998244353;
      | ^~
answer.code:8:1: error: ‘ll’ does not name a type
    8 | ll L[N];
      | ^~
answer.code:11:1: error: ‘ll’ does not name a type
   11 | ll f[N];
      | ^~
answer.code:12:1: error: ‘ll’ does not name a type
   12 | ll g[N][N];
      | ^~
answer.code:13:1: error: ‘ll’ does not name a type
   13 | ll dp[N][N];
      | ^~
answer.code:14:1: error: ‘ll’ does not name a type
   14 | ll S[N][N];
      | ^~
answer.code:15:1: error: ‘ll’ does not name a type
   15 | ll ans[N];
      | ^~
answer.code:16:1: error: ‘ll’ does not name a type
   16 | ll fast_pow(ll a,ll m)
      | ^~
answer.code:28:1: error: ‘ll’ does not name a type
   28 | ll mod_inverse(ll x)
      | ^~
answer.code:32:1: error: ‘ll’ does not name a type
   32 | ll C(ll x,ll y)
      | ^~
answer.code: In function ‘void dfs_1(int, int)’:
answer.code:38:14: error: ‘L’ was not declared in this scope
   38 |     int temp=L[sz[u]-1];
      |              ^
answer.code:43:15: error: ‘ll’ was not declared in this scope
   43 |         temp=(ll)((temp*1ll*f[v])%mod);
      |               ^~
answer.code:43:29: error: ‘f’ was not declared in this scope
   43 |         temp=(ll)((temp*1ll*f[v])%mod);
      |                             ^
answer.code:43:35: error: ‘mod’ was not declared in this scope; did you mean ‘modf’?
   43 |         temp=(ll)((temp*1ll*f[v])%mod);
      |                                   ^~~
      |                                   modf
answer.code:44:29: error: ‘mod_inverse’ was not declared in this scope
   44 |         temp=(ll)((temp*1ll*mod_inverse(L[sz[v]]))%mod);
      |                             ^~~~~~~~~~~
answer.code:47:5: error: ‘f’ was not declared in this scope
   47 |     f[u]=temp;
      |     ^
answer.code:51:9: error: ‘g’ was not declared in this scope
   51 |         g[u][v]=(ll)((((f[u]*1ll*mod_inverse(f[v]))%mod)*mod_inverse(C(sz[u]-1,sz[v])))%mod);
      |         ^
answer.code:51:18: error: ‘ll’ was not declared in this scope
   51 |         g[u][v]=(ll)((((f[u]*1ll*mod_inverse(f[v]))%mod)*mod_inverse(C(sz[u]-1,sz[v])))%mod);
      |                  ^~
answer.code:51:34: error: ‘mod_inverse’ was not declared in this scope
   51 |         g[u][v]=(ll)((((f[u]*1ll*mod_inverse(f[v]))%mod)*mod_inverse(C(sz[u]-1,sz[v])))%mod);
      |                                  ^~~~~~~~~~~
answer.code:51:53: error: ‘mod’ was not declared in this scope; did you mean ‘modf’?
   51 |         g[u][v]=(ll)((((f[u]*1ll*mod_inverse(f[v]))%mod)*mod_inverse(C(sz[u]-1,sz[v])))%mod);
      |                                                     ^~~
      |                                                     modf
answer.code:51:70: error: ‘C’ was not declared in this scope
   51 |         g[u][v]=(ll)((((f[u]*1ll*mod_inverse(f[v]))%mod)*mod_inverse(C(sz[u]-1,sz[v])))%mod);
      |                                                                      ^
answer.code: In function ‘void dfs_2(int, int)’:
answer.code:60:13: error: ‘S’ was not declared in this scope
   60 |             S[fa][i]=(ll)(((S[fa][i-1]*1ll+(dp[fa][i]*1ll*C(n-sz[u]-i,sz[fa]-sz[u]-1))%mod))%mod);
      |             ^
answer.code:60:23: error: ‘ll’ was not declared in this scope
   60 |             S[fa][i]=(ll)(((S[fa][i-1]*1ll+(dp[fa][i]*1ll*C(n-sz[u]-i,sz[fa]-sz[u]-1))%mod))%mod);
      |                       ^~
answer.code:60:45: error: ‘dp’ was not declared in this scope; did you mean ‘p’?
   60 |             S[fa][i]=(ll)(((S[fa][i-1]*1ll+(dp[fa][i]*1ll*C(n-sz[u]-i,sz[fa]-sz[u]-1))%mod))%mod);
      |                                             ^~
      |                                             p
answer.code:60:59: error: ‘C’ was not declared in this scope
   60 |             S[fa][i]=(ll)(((S[fa][i-1]*1ll+(dp[fa][i]*1ll*C(n-sz[u]-i,sz[fa]-sz[u]-1))%mod))%mod);
      |                                                           ^
answer.code:60:88: error: ‘mod’ was not declared in this scope; did you mean ‘modf’?
   60 |             S[fa][i]=(ll)(((S[fa][i-1]*1ll+(dp[fa][i]*1ll*C(n-sz[u]-i,sz[fa]-sz[u]-1))%mod))%mod);
      |                                                                                        ^~~
      |                                                                                        modf
answer.code:61:27: error: ‘g’ was not declared in this scope
   61 |             dp[u][i]=(ll)(g[fa][u]*1ll*S[fa][i-1])%mod;
      |                           ^
answer.code: In function ‘int main()’:
answer.code:72:15: warning: format ‘%lld’ expects argument of type ‘long long int*’, but argument 2 has type ‘int*’ [-Wformat=]
   72 |     scanf("%lld",&n);
      |            ~~~^  ~~
      |               |  |
      |               |  int*
      |               long long int*
      |            %d
answer.code:73:5: error: ‘L’ was...