Submission #1651288
Source Code Expand
int getfa(int x){ return x==fa[x]?x:fa[x]=getfa(fa[x]); } void mrg(int x,int y){ x=getfa(x); y=getfa(y); if (x==y) return; sz[y]+=sz[x]; sum[y]+=sum[x]; fa[x]=y; } void dfs(int x,int p){ int i,y; vis[x]=1; for (i=fst[x]; i; i=nxt[i]) if (i^p^1){ y=pnt[i]; if (!vis[y]){ dad[y]=x; d[y]=d[x]+1; eg[y]=i>>1; bo[i>>1]=1; sz[i>>1]=0; dfs(y,i); } } } int main(){ scanf("%d%d%d",&n,&m,&K); int i,j,x,y; for (i=0; i<=n+K; i++) for (j=cbn[i][0]=1; j<=i; j++) cbn[i][j]=(cbn[i-1][j]+cbn[i-1][j-1])%mod; for (i=1; i<=m; i++){ scanf("%d%d",&x,&y); add(x,y); add(y,x); } for (i=1; i<=m; i++){ fa[i]=i; sz[i]=sum[i]=1; } for (i=1; i<=n; i++) if (!vis[i]) dfs(i,0); for (i=1; i<=m; i++) if (!bo[i]){ x=pnt[i<<1]; y=pnt[i<<1|1]; if (d[x]<d[y]) swap(x,y); for (; x!=y; x=dad[x]) mrg(eg[x],i); } int ans=1; for (i=1; i<=m; i++) if (getfa(i)==i){ if (sz[i]>1) ans=(ll)ans*cbn[sum[i]+K-1][K-1]%mod; else{ for (j=1,x=0; j<=sum[i]; j++) x=(x+ksm(K,gcd(j,sum[i])))%mod; ans=(ll)ans*x%mod*ksm(sum[i],mod-2)%mod; } } printf("%d\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Painting Graphs with AtCoDeer |
User | lych_cys |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1147 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int getfa(int)’: ./Main.cpp:2:29: error: ‘fa’ was not declared in this scope int getfa(int x){ return x==fa[x]?x:fa[x]=getfa(fa[x]); } ^ ./Main.cpp: In function ‘void mrg(int, int)’: ./Main.cpp:6:2: error: ‘sz’ was not declared in this scope sz[y]+=sz[x]; sum[y]+=sum[x]; fa[x]=y; ^ ./Main.cpp:6:16: error: ‘sum’ was not declared in this scope sz[y]+=sz[x]; sum[y]+=sum[x]; fa[x]=y; ^ ./Main.cpp:6:32: error: ‘fa’ was not declared in this scope sz[y]+=sz[x]; sum[y]+=sum[x]; fa[x]=y; ^ ./Main.cpp: In function ‘void dfs(int, int)’: ./Main.cpp:9:11: error: ‘vis’ was not declared in this scope int i,y; vis[x]=1; ^ ./Main.cpp:10:9: error: ‘fst’ was not declared in this scope for (i=fst[x]; i; i=nxt[i]) if (i^p^1){ ^ ./Main.cpp:10:22: error: ‘nxt’ was not declared in this scope for (i=fst[x]; i; i=nxt[i]) if (i^p^1){ ^ ./Main.cpp:11:5: error: ‘pnt’ was not...