QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#779822 | #9566. Topology | Idtwtei# | Compile Error | / | / | C++14 | 1.5kb | 2024-11-24 22:00:35 | 2024-11-24 22:00:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=5e3+100,MOD=998244353;
inline void mod(int &x){ if(x>=MOD) x-=MOD; }
inline int qm(int x,int y=MOD-2){ int res=1; for(;y;y>>=1,x=1ll*x*x%MOD) if(y&1) res=1ll*res*x%MOD; return res; }
#define gc getchar()
#define rd read()
inline int read(){
int x=0,f=0; char c=gc;
for(;c<'0'||c>'9';c=gc) f|=(c=='-');
for(;c>='0'&&c<='9';c=gc) x=(x<<1)+(x<<3)+(c^48);
return f?-x:x;
}
int jc[N],fjc[N];
void init(int n){
jc[0]=1; for(int i=1;i<=n;++i) jc[i]=1ll*jc[i-1]*i%MOD;
fjc[n]=qm(jc[n]); for(int i=n-1;~i;--i) fjc[i]=1ll*fjc[i+1]*(i+1)%MOD;
}
inline int C(int n,int m){ return n<0||m<0||m>n?0:1ll*jc[n]*fjc[m]%MOD*fjc[n-m]%MOD; }
int n,mul[N],siz[N],fmul[N],f[N][N];
vector<int> G[N];
void dfs0(int u){ siz[u]=mul[u]=1; for(int v:G[u]) dfs0(v),siz[u]+=siz[v],mul[u]=1ll*mul[u]*mul[v]%MOD; mul[u]=1ll*mul[u]*siz[u]%MOD; }
void dfs1(int u){
for(int v:G[u]){
for(int i=1,sum=0,p,q;i<=n;++i){
p=1ll*sum*jc[siz[u]-siz[v]-1]%MOD;
q=1ll*fmul[u]*siz[u]%MOD*mul[v]%MOD;
f[v][i]=1ll*p*q%MOD;
mod(sum+=1ll*f[u][i]*C(n-i-siz[v],siz[u]-siz[v]-1)%MOD);
}
dfs1(v);
}
}
int main(){
init(n=rd); for(int i=2;i<=n;++i) G[rd].pb(i);
dfs0(1);
for(int i=1;i<=n;++i) fmul[i]=qm(mul[i]);
f[1][1]=1;
dfs1(1);
for(int i=1,p,q;i<=n;++i){
p=1ll*f[i][i]*C(n-i,siz[i]-1)%MOD;
q=1ll*jc[siz[i]]*fmul[i]%MOD;
printf("%d ", 1ll*p*q%MOD);
}
return 0;
}
Details
answer.code:24:27: error: ‘int fmul [5100]’ redeclared as different kind of entity 24 | int n,mul[N],siz[N],fmul[N],f[N][N]; | ^ In file included from /usr/include/c++/13/cmath:47, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:114, from answer.code:1: /usr/include/x86_64-linux-gnu/bits/mathcalls-narrow.h:30:20: note: previous declaration ‘float fmul(double, double)’ 30 | __MATHCALL_NARROW (__MATHCALL_NAME (mul), __MATHCALL_REDIR_NAME (mul), 2); | ^~~~~~~~~~~~~~~ answer.code: In function ‘void dfs1(int)’: answer.code:32:37: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | q=1ll*fmul[u]*siz[u]%MOD*mul[v]%MOD; | ^ answer.code:32:30: error: invalid operands of types ‘long long int’ and ‘float(double, double) throw ()’ {aka ‘float(double, double)’} to binary ‘operator*’ 32 | q=1ll*fmul[u]*siz[u]%MOD*mul[v]%MOD; | ~~~^~~~~~~~ | | | | | float(double, double) throw () {aka float(double, double)} | long long int answer.code: In function ‘int main()’: answer.code:45:37: warning: pointer to a function used in arithmetic [-Wpointer-arith] 45 | for(int i=1;i<=n;++i) fmul[i]=qm(mul[i]); | ^ answer.code:45:38: error: assignment of read-only location ‘*(fmul + ((sizetype)i))’ 45 | for(int i=1;i<=n;++i) fmul[i]=qm(mul[i]); | ~~~~~~~^~~~~~~~~~~ answer.code:51:40: warning: pointer to a function used in arithmetic [-Wpointer-arith] 51 | q=1ll*jc[siz[i]]*fmul[i]%MOD; | ^ answer.code:51:33: error: invalid operands of types ‘long long int’ and ‘float(double, double) throw ()’ {aka ‘float(double, double)’} to binary ‘operator*’ 51 | q=1ll*jc[siz[i]]*fmul[i]%MOD; | ~~~~~~~~~~~~~~^~~~~~~~ | | | | long long int float(double, double) throw () {aka float(double, double)} answer.code:52:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] 52 | printf("%d ", 1ll*p*q%MOD); | ~^ ~~~~~~~~~~~ | | | | int long long int | %lld