#include <bits/stdc++.h>
using namespace std;
int N, flag, cyc, up[1000005], par[1000005];
vector<int> edge[1000005], ans;
bool vis[1000005];
int fnd(int x) { return up[x] == x ? x : up[x] = fnd(up[x]); }
void Init(int N_) {
N = N_;
for (int i = 0; i < N; ++i) {
up[i] = i;
ans.push_back(i);
}
}
void update(int x) {
if (vis[x] || edge[x].size() < 3) return;
vis[x] = 1;
vector<int> v;
for (auto i : ans) {
if (i == x) v.push_back(i);
else for (auto j : edge[x]) if (i == j) {
v.push_back(i);
break;
}
}
ans = v;
}
void Link(int a, int b) {
if (ans.empty()) return;
edge[a].push_back(b);
edge[b].push_back(a);
update(a);
update(b);
}
bool vi[1000005];
int dep[1000005];
void dfs(int x, int p) {
vi[x] = 1;
for (auto i : edge[x]) if (i != p) {
if (vi[i]) {
if (dep[i] < dep[x]) {
vector<int> u, v;
u.push_back(i);
for (int j = x; j != i; j = par[j]) u.push_back(j);
for (auto i : ans) {
for (auto j : u) if (i == j) {
v.push_back(i);
break;
}
}
ans = v;
}
continue;
}
par[i] = x;
dep[i] = dep[x] + 1;
dfs(i, x);
}
}
int CountCritical() {
for (int i = 0; i < N; ++i) vi[i] = 0;
for (int i = 0; i < N; ++i) if (!vi[i]) {
dep[i] = 0;
dfs(i, i);
}
return ans.size();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
23808 KB |
Output is correct |
2 |
Incorrect |
20 ms |
24184 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
513 ms |
55784 KB |
Output is correct |
2 |
Incorrect |
970 ms |
73824 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
23808 KB |
Output is correct |
2 |
Incorrect |
20 ms |
24184 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
23808 KB |
Output is correct |
2 |
Incorrect |
20 ms |
24184 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
23808 KB |
Output is correct |
2 |
Incorrect |
20 ms |
24184 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |