Submission #1811519
Source Code Expand
#include<bits/stdc++.h> using namespace std; const int N = 55, P = 1e9 + 7, M = 205; int n, m, k, dfn[N], cn[N], ans = 1, low[N], bl[N], cnt, stu[N], stv[N], top, tot, C[M][M], si[N], Gr[N]; vector<int>V[N]; void Min (int &x, int y) { if (x > y) x = y; } void Tarjan (int x, int fa) { dfn[x] = low[x] = ++cnt; for (auto v : V[x]) if (v != fa) { if (!dfn[v]) { int la = ++top; stu[top] = x; stv[top] = v; Tarjan(v, x); if (low[v] > dfn[x]) { ans = 1ll * ans * k; top = la - 1; continue ; } if (low[v] == dfn[x]) { for (++tot; top >= la; --top, ++cn[tot]) { if (bl[stu[top]] != tot) { bl[stu[top]] = tot; ++si[tot]; cn[tot] += Gr[stu[top]]; } if (bl[stv[top]] != tot) { bl[stv[top]] = tot; ++si[tot]; cn[tot] += Gr[stv[top]]; } } cn[tot] -= Gr[x]; } else Min(low[x], low[v]); } else if (dfn[v] <= dfn[x]) Min(low[x], dfn[v]), ++Gr[x]; } } int qp (int a, int b) { int c = 1; for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P; return c; } int gcd (int a, int b) { return b ? gcd(b, a % b) : a; } int main () { scanf("%d%d%d", &n, &m, &k); C[0][0] = 1; for (int i = 1; i <= m + k; ++i) { C[i][0] = 1; for (int j = 1; j <= i; ++j) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % P; } for (int i = 0, u, v; i < m; ++i) { scanf("%d%d", &u, &v); V[u].emplace_back(v); V[v].emplace_back(u); } for (int i = 1; i <= n; ++i) if (!dfn[i]) Tarjan(i, 0); // si[2] = 5; cn[2] = 5; ++tot; si[tot] = 4; cn[tot] = 5; for (int i = 1; i <= tot; ++i) { if (si[i] == 1) continue ; if (si[i] != cn[i]) ans = 1ll * ans * C[cn[i] + k - 1][k - 1] % P; else { int tmp = 0, n = cn[i]; for (int i = 0; i < n; ++i) tmp = (tmp + qp(k, gcd(i, n))) % P; tmp = 1ll * tmp * qp(n, P - 2) % P; ans = 1ll * ans * tmp % P; } } printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Painting Graphs with AtCoDeer |
User | DraZxlNDdt |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1939 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 384 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:42:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d%d", &n, &m, &k); ^ ./Main.cpp:49:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &u, &v); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | AC | 1 ms | 256 KB |
1_003.txt | AC | 1 ms | 256 KB |
1_004.txt | WA | 1 ms | 384 KB |
1_005.txt | WA | 1 ms | 384 KB |
1_006.txt | AC | 1 ms | 384 KB |
1_007.txt | AC | 1 ms | 256 KB |
1_008.txt | AC | 1 ms | 256 KB |
1_009.txt | AC | 1 ms | 256 KB |
1_010.txt | AC | 1 ms | 256 KB |
1_011.txt | AC | 1 ms | 256 KB |
1_012.txt | AC | 1 ms | 384 KB |
1_013.txt | AC | 1 ms | 384 KB |
1_014.txt | AC | 1 ms | 384 KB |
1_015.txt | AC | 1 ms | 384 KB |
1_016.txt | AC | 1 ms | 384 KB |
1_017.txt | AC | 1 ms | 384 KB |
1_018.txt | AC | 1 ms | 384 KB |
1_019.txt | AC | 1 ms | 384 KB |
1_020.txt | AC | 1 ms | 384 KB |
1_021.txt | AC | 1 ms | 384 KB |
1_022.txt | AC | 1 ms | 384 KB |
1_023.txt | AC | 1 ms | 384 KB |
1_024.txt | AC | 1 ms | 384 KB |
1_025.txt | AC | 1 ms | 384 KB |
1_026.txt | AC | 1 ms | 384 KB |
1_027.txt | AC | 1 ms | 384 KB |
1_028.txt | AC | 1 ms | 256 KB |
1_029.txt | AC | 1 ms | 256 KB |
1_030.txt | AC | 1 ms | 256 KB |
1_031.txt | AC | 1 ms | 384 KB |
1_032.txt | AC | 1 ms | 256 KB |
1_033.txt | AC | 1 ms | 256 KB |
1_034.txt | AC | 1 ms | 256 KB |
1_035.txt | AC | 1 ms | 384 KB |
1_036.txt | WA | 1 ms | 384 KB |
1_037.txt | AC | 1 ms | 384 KB |
1_038.txt | AC | 1 ms | 384 KB |
1_039.txt | AC | 1 ms | 384 KB |
1_040.txt | AC | 1 ms | 256 KB |
1_041.txt | AC | 1 ms | 256 KB |
1_042.txt | AC | 1 ms | 256 KB |
1_043.txt | AC | 1 ms | 384 KB |
1_044.txt | WA | 1 ms | 256 KB |
1_045.txt | AC | 1 ms | 384 KB |
1_046.txt | AC | 1 ms | 384 KB |
1_047.txt | AC | 1 ms | 384 KB |
1_048.txt | WA | 1 ms | 384 KB |
1_049.txt | AC | 1 ms | 384 KB |
1_050.txt | AC | 1 ms | 384 KB |
1_051.txt | AC | 1 ms | 384 KB |
1_052.txt | AC | 1 ms | 256 KB |
1_053.txt | AC | 1 ms | 256 KB |
1_054.txt | AC | 1 ms | 256 KB |
1_055.txt | AC | 1 ms | 384 KB |
1_056.txt | AC | 1 ms | 256 KB |
1_057.txt | AC | 1 ms | 256 KB |
1_058.txt | AC | 1 ms | 256 KB |
1_059.txt | AC | 1 ms | 384 KB |
1_060.txt | WA | 1 ms | 384 KB |
1_061.txt | WA | 1 ms | 384 KB |
1_062.txt | WA | 1 ms | 384 KB |
1_063.txt | AC | 1 ms | 384 KB |