Submission #1692967
Source Code Expand
#include <bits/stdc++.h> #define N 210 #define mod 1000000007 using namespace std; typedef long long ll; inline int read() { int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();} return x*f; } struct edge { int u,v,next; }vs[N<<1]; int n,m,k,st[N],ee,sta[N],top,las; int bl[N],dfn[N],low[N],tot,Ans=1,c[N][N]; inline int qpow(int bas,int pw) { int ret=1; for(;pw;pw>>=1,bas=1ll*bas*bas%mod) if(pw&1) ret=1ll*bas*ret%mod; return ret; } inline void addedge(int u,int v) { vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee; } inline int polya(int n) { int ret=0; for(int i=1;i<=n;i++) ret=(ret+qpow(k,__gcd(i,n)))%mod; return 1ll*ret*qpow(n,mod-2)%mod; } inline void calc(int x,int y) { //cerr << x << " " << y << endl; int cnt=1,bcnt=0; bl[x]=++tot; while(sta[top]!=y) bl[sta[top]]=tot,top--,cnt++; top--; bl[y]=tot; cnt++; if(cnt==2) {Ans=1ll*Ans*k%mod; return ;} for(int i=1;i<=n;i++) if(bl[i]==tot) for(int j=st[i];j;j=vs[j].next) if(bl[vs[j].v]==tot) bcnt++; bcnt>>=1; if(bcnt==cnt) Ans=1ll*Ans*polya(cnt)%mod; else Ans=1ll*Ans*c[bcnt+k-1][k-1]%mod; } inline void dfs(int rt,int pr) { dfn[rt]=low[rt]=++las; sta[++top]=rt; for(int i=st[rt];i;i=vs[i].next) { if(vs[i].v==pr) continue; if(!dfn[vs[i].v]) { dfs(vs[i].v,rt);low[rt]=min(low[rt],low[vs[i].v]); if(low[vs[i].v]>=dfn[rt]) calc(rt,vs[i].v); } else low[rt]=min(low[rt],dfn[vs[i].v]); } } int main() { c[0][0]=1; for(int i=1;i<=200;i++) { c[i][0]=1; for(int j=1;j<=200;j++) c[i][j]=(1ll*c[i-1][j]+1ll*c[i-1][j-1])%mod; } n=read(); m=read(); k=read(); for(int i=1;i<=m;i++) { int u=read(), v=read(); addedge(u,v); addedge(v,u); } for(int i=1;i<=n;i++) if(!dfn[i]) dfs(i,0); cout << Ans << endl; return 0 ; }
Submission Info
Submission Time | |
---|---|
Task | F - Painting Graphs with AtCoDeer |
User | wcz111 |
Language | C++14 (GCC 5.4.1) |
Score | 1300 |
Code Size | 1894 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 384 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1300 / 1300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt, 1_031.txt, 1_032.txt, 1_033.txt, 1_034.txt, 1_035.txt, 1_036.txt, 1_037.txt, 1_038.txt, 1_039.txt, 1_040.txt, 1_041.txt, 1_042.txt, 1_043.txt, 1_044.txt, 1_045.txt, 1_046.txt, 1_047.txt, 1_048.txt, 1_049.txt, 1_050.txt, 1_051.txt, 1_052.txt, 1_053.txt, 1_054.txt, 1_055.txt, 1_056.txt, 1_057.txt, 1_058.txt, 1_059.txt, 1_060.txt, 1_061.txt, 1_062.txt, 1_063.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 2 ms | 384 KB |
0_001.txt | AC | 2 ms | 384 KB |
0_002.txt | AC | 2 ms | 384 KB |
1_003.txt | AC | 2 ms | 384 KB |
1_004.txt | AC | 2 ms | 384 KB |
1_005.txt | AC | 2 ms | 384 KB |
1_006.txt | AC | 2 ms | 384 KB |
1_007.txt | AC | 2 ms | 384 KB |
1_008.txt | AC | 2 ms | 384 KB |
1_009.txt | AC | 2 ms | 384 KB |
1_010.txt | AC | 2 ms | 384 KB |
1_011.txt | AC | 2 ms | 384 KB |
1_012.txt | AC | 2 ms | 384 KB |
1_013.txt | AC | 2 ms | 384 KB |
1_014.txt | AC | 2 ms | 384 KB |
1_015.txt | AC | 2 ms | 384 KB |
1_016.txt | AC | 2 ms | 384 KB |
1_017.txt | AC | 2 ms | 384 KB |
1_018.txt | AC | 2 ms | 384 KB |
1_019.txt | AC | 2 ms | 384 KB |
1_020.txt | AC | 2 ms | 384 KB |
1_021.txt | AC | 2 ms | 384 KB |
1_022.txt | AC | 2 ms | 384 KB |
1_023.txt | AC | 2 ms | 384 KB |
1_024.txt | AC | 2 ms | 384 KB |
1_025.txt | AC | 2 ms | 384 KB |
1_026.txt | AC | 2 ms | 384 KB |
1_027.txt | AC | 2 ms | 384 KB |
1_028.txt | AC | 2 ms | 384 KB |
1_029.txt | AC | 2 ms | 384 KB |
1_030.txt | AC | 2 ms | 384 KB |
1_031.txt | AC | 2 ms | 384 KB |
1_032.txt | AC | 2 ms | 384 KB |
1_033.txt | AC | 2 ms | 384 KB |
1_034.txt | AC | 2 ms | 384 KB |
1_035.txt | AC | 2 ms | 384 KB |
1_036.txt | AC | 2 ms | 384 KB |
1_037.txt | AC | 2 ms | 384 KB |
1_038.txt | AC | 2 ms | 384 KB |
1_039.txt | AC | 2 ms | 384 KB |
1_040.txt | AC | 2 ms | 384 KB |
1_041.txt | AC | 2 ms | 384 KB |
1_042.txt | AC | 2 ms | 384 KB |
1_043.txt | AC | 2 ms | 384 KB |
1_044.txt | AC | 2 ms | 384 KB |
1_045.txt | AC | 2 ms | 384 KB |
1_046.txt | AC | 2 ms | 384 KB |
1_047.txt | AC | 2 ms | 384 KB |
1_048.txt | AC | 2 ms | 384 KB |
1_049.txt | AC | 2 ms | 384 KB |
1_050.txt | AC | 2 ms | 384 KB |
1_051.txt | AC | 2 ms | 384 KB |
1_052.txt | AC | 2 ms | 384 KB |
1_053.txt | AC | 2 ms | 384 KB |
1_054.txt | AC | 2 ms | 384 KB |
1_055.txt | AC | 2 ms | 384 KB |
1_056.txt | AC | 2 ms | 384 KB |
1_057.txt | AC | 2 ms | 384 KB |
1_058.txt | AC | 2 ms | 384 KB |
1_059.txt | AC | 2 ms | 384 KB |
1_060.txt | AC | 2 ms | 384 KB |
1_061.txt | AC | 2 ms | 384 KB |
1_062.txt | AC | 2 ms | 384 KB |
1_063.txt | AC | 2 ms | 384 KB |