Language: C++


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;
}


Compiler output:
a.cc: In function 'int getfa(int)':
a.cc:2:29: error: 'fa' was not declared in this scope
    2 | int getfa(int x){ return x==fa[x]?x:fa[x]=getfa(fa[x]); }
      |                             ^~
a.cc: In function 'void mrg(int, int)':
a.cc:6:9: error: 'sz' was not declared in this scope
    6 |         sz[y]+=sz[x]; sum[y]+=sum[x]; fa[x]=y;
      |         ^~
a.cc:6:23: error: 'sum' was not declared in this scope
    6 |         sz[y]+=sz[x]; sum[y]+=sum[x]; fa[x]=y;
      |                       ^~~
a.cc:6:39: error: 'fa' was not declared in this scope
    6 |         sz[y]+=sz[x]; sum[y]+=sum[x]; fa[x]=y;
      |                                       ^~
a.cc: In function 'void dfs(int, int)':
a.cc:9:18: error: 'vis' was not declared in this scope
    9 |         int i,y; vis[x]=1;
      |                  ^~~
a.cc:10:16: error: 'fst' was not declared in this scope
   10 |         for (i=fst[x]; i; i=nxt[i]) if (i^p^1){
      |                ^~~
a.cc:10:29: error: 'nxt' was not declared in this scope
   10 |         for (i=fst[x]; i; i=nxt[i]) if (i^p^1){
      |                             ^~~
a.cc:11:19: error: 'pnt' was not declared in this scope; did you mean 'int'?
   11 |                 y=pnt[i];
      |                   ^~~
      |                   int
a.cc:13:25: error: 'dad' was not declared in this scope
   13 |                         dad[y]=x; d[y]=d[x]+1;
      |                         ^~~
a.cc:13:35: error: 'd' was not declared in this scope
   13 |                         dad[y]=x; d[y]=d[x]+1;
      |                                   ^
a.cc:14:25: error: 'eg' was not declared in this scope
   14 |                         eg[y]=i>>1; bo[i>>1]=1; sz[i>>1]=0;
      |                         ^~
a.cc:14:37: error: 'bo' was not declared in this scope
   14 |                         eg[y]=i>>1; bo[i>>1]=1; sz[i>>1]=0;
      |                                     ^~
a.cc:14:49: error: 'sz' was not declared in this scope
   14 |                         eg[y]=i>>1; bo[i>>1]=1; sz[i>>1]=0;
      |                                                 ^~
a.cc: In function 'int main()':
a.cc:20:25: error: 'n' was not declared in this scope
   20 |         scanf("%d%d%d",&n,&m,&K);
      |                         ^
a.cc:20:28: error: 'm' was not declared in this scope
   20 |         scanf("%d%d%d",&n,&m,&K);
      |                            ^
a.cc:20:31: error: 'K' was not declared in this scope
   20 |         scanf("%d%d%d",&n,&m,&K);
      |                               ^
a.cc:20:9: error: 'scanf' was not declared in this scope
   20 |         scanf("%d%d%d",&n,&m,&K);
      |         ^~~~~
a.cc:23:24: error: 'cbn' was not declared in this scope
   23 |                 for (j=cbn[i][0]=1; j<=i; j++)
      |                        ^~~
a.cc:24:63: error: 'mod' was not declared in this scope
   24 |                         cbn[i][j]=(cbn[i-1][j]+cbn[i-1][j-1])%mod;
      |                                                               ^~~
a.cc:27:17: error: 'add' was not declared in this scope
   27 |                 add(x,y); add(y,x);
      |                 ^~~
a.cc:30:17: error: 'fa' was not declared in this scope
   30 |                 fa[i]=i; sz[i]=sum[i]=1;
      |                 ^~
a.cc:30:26: error: 'sz' was not declared in this scope
   30 |                 fa[i]=i; sz[i]=sum[i]=1;
      |                          ^~
a.cc:30:32: error: 'sum' was not declared in this scope
   30 |                 fa[i]=i; sz[i]=sum[i]=1;
      |                                ^~~
a.cc:32:35: error: 'vis' was not declared in this scope
   32 |         for (i=1; i<=n; i++) if (!vis[i]) dfs(i,0);
      |                                   ^~~
a.cc:33:35: error: 'bo' was not declared in this scope
   33 |         for (i=1; i<=m; i++) if (!bo[i]){
      |                                   ^~
a.cc:34:19: error: 'pnt' was not declared in this scope; did you mean 'int'?
   34 |                 x=pnt[i<<1]; y=pnt[i<<1|1];
      |                   ^~~
      |                   int
a.cc:35:21: error: 'd' was not declared in this scope
   35 |                 if (d[x]<d[y]) swap(x,y);
      |                     ^
a.cc:35:32: error: 'swap' was not declared in this scope
   35 |                 if (d[x]<d[y]) swap(x,y);
      |                                ^~~~
a.cc:36:32: error: 'dad' was not declared in this scope
   36 |                 for (; x!=y; x=dad[x]) mrg(eg[x],i);
      |                                ^~~
a.cc:36:44: error: 'eg' was not declared in this scope
   36 |                 for (; x!=y; x=dad[x]) mrg(eg[x],i);
      |                                            ^~
a.cc:40:21: error: 'sz' was not declared in this scope
   40 |                 if (sz[i]>1)
      |                     ^~
a.cc:41:30: error: 'll' was not declared in this scope
   41 |                         ans=(ll)ans*cbn[sum[i]+K-1][K-1]%mod;
      |                              ^~
a.cc:43:42: error: 'sum' was not declared in this scope
   43 |                         for (j=1,x=0; j<=sum[i]; j++)
      |                                          ^~~
a.cc:44:44: error: 'gcd' was not declared in this scope
   44 |                                 x=(x+ksm(K,gcd(j,sum[i])))%mod;
      |                                            ^~~
a.cc:44:38: error: 'ksm' was not declared in this scope
   44 |                                 x=(x+ksm(K,gcd(j,sum[i])))%mod;
      |                                      ^~~
a.cc:44:60: error: 'mod' was not declared in this scope
   44 |                                 x=(x+ksm(K,gcd(j,sum[i])))%mod;
      |                                                            ^~~
a.cc:45:30: error: 'll' was not declared in this scope
   45 |                         ans=(ll)ans*x%mod*ksm(sum[i],mod-2)%mod;
      |                              ^~
a.cc:48:9: error: 'printf' was not declared in this scope
   48 |         printf("%d\n",ans);
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 |