1 条题解
-
0

#include <bits/stdc++.h> #define ad(x) (((x - 1) ^ 1) + 1) using std::cin; using std::cout; typedef long long ll; const int N = 2054, M = N * 2; struct edge { int u, v; edge (int u0 = 0, int v0 = 0) : u(u0), v(v0) {} } e[M]; int V, E, C, Es = 0; int first[N], next[M]; int cnt = 0, id[N], low[N]; int col[M], count[N]; bool banned[M]; inline void down(int &x, const int y) {x > y ? x = y : 0;} inline void addedge(int u, int v) { e[++Es] = edge(u, v), next[Es] = first[u], first[u] = Es; e[++Es] = edge(v, u), next[Es] = first[v], first[v] = Es; } void dfs(int x, int px = 0) { int i, y; id[x] = low[x] = ++cnt; for (i = first[x]; i; i = next[i]) if (!banned[i] && ~col[i]) { if (!id[y = e[i].v]) { dfs(y, x), down(low[x], low[y]); if (id[x] < low[y]) assert(!col[i]), col[i] = col[ad(i)] = C; } else if (y != px) down(low[x], id[y]); } } inline void coloring() { cnt = 0, memset(id, 0, (V + 1) << 2); for (int i = 1; i <= V; ++i) if (!id[i]) dfs(i); } int main() { int i, u, v, d = 0; std::ios::sync_with_stdio(false), cin.tie(NULL); cin >> V >> E; for (i = 1; i <= E; ++i) cin >> u >> v, addedge(u, v); C = -1, coloring(), C = 0; for (i = 1; i <= Es; i += 2) if (!col[i]) banned[i] = banned[i + 1] = true, col[i] = col[i + 1] = ++C, coloring(), banned[i] = banned[i + 1] = false; for (i = 1; i <= Es; i += 2) ++count[col[i]]; for (i = 1; i <= C; ++i) d = std::__gcd(d, count[i]); for (i = 1; i < d; ++i) if (!(d % i)) cout << i << ' '; cout << d << '\n'; return 0; }
- 1
信息
- ID
- 5781
- 时间
- 2000ms
- 内存
- 512MiB
- 难度
- 10
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者