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>
//#include "rings.h"
using namespace std;
const int N = 5e3 + 5;
int n;
vector<int> v[N];
bool vis[N], ok;
int deg[N], nod;
void dfs(int s, int p) {
vis[s] = 1;
if(deg[s] > 2) ok = false;
for(auto i : v[s]) {
if(i != p && i != nod) {
if(vis[i] == 0) {
dfs(i,s);
}
else {
ok = false;
}
}
}
}
void Init(int N_) {
n = N_;
}
void Link(int A, int B) {
deg[A]++; deg[B]++;
v[A].push_back(B);
v[B].push_back(A);
}
int CountCritical() {
int sol = 0;
for(int i = 0; i < n; i++) {
nod = i; ok = true;
for(auto j : v[i]) deg[j]--;
for(int j = 0; j < n; j++) vis[j] = 0;
for(int j = 0; j < n; j++) {
if(vis[j] == 0 && j != nod) {
dfs(j,-1);
}
}
if(ok) sol++;
for(auto j : v[i]) deg[j]++;
}
return sol;
}
# | 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... |