This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[200005], vis;
int n, ans = 0;
bool f = 1;
void Init(int N_) {
n = N_;
ans = n;
}
void dfs(int i, int p, int s) {
if (vis[i]) {
f = 0;
return;
}
vis[i] = 1;
for (int j : adj[i]) {
if (j == p || j == s) {
continue;
}
dfs(j, i, s);
}
}
int calc(int a) {
vis.resize(n, 0);
vector<int> co(n, 0);
for (int j : adj[a]) {
co[j]++;
}
f = 1;
for (int i = 0; i < n; i++) {
if (i != a && adj[i].size()-co[i] > 2) {
f = 0;
break;
}
if (vis[i] || i == a) {
continue;
}
dfs(i, -1, a);
}
vis.clear();
return f;
}
void Link(int A, int B) {
adj[A].push_back(B);
adj[B].push_back(A);
ans = 0;
for (int i = 0; i < n; i++) {
ans += calc(i);
}
}
int CountCritical() {
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |