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/extc++.h"
using namespace std;
template <typename T>
void dbgh(const T& t) {
cerr << t << endl;
}
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t << " | ";
dbgh(u...);
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
dbgh(__VA_ARGS__);
#else
#define dbg(...)
#define cerr \
if (false) \
cerr
#endif
#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())
const int maxn = 5e3 + 5;
int n, ign;
bool bad, vis[maxn];
vector<int> graph[maxn];
void dfs(int u, int p = -1) {
if (vis[u]) {
bad = true;
return;
}
vis[u] = true;
for (auto& v : graph[u]) {
if (v != p && v != ign) {
dfs(v, u);
}
}
}
void Init(int _n) {
n = _n;
}
void Link(int u, int v) {
graph[u].push_back(v);
graph[v].push_back(u);
}
int CountCritical() {
int ans = 0;
for (int i = 0; i < n; i++) {
ign = i;
bad = false;
memset(vis, 0, sizeof(vis));
for (int j = 0; j < n; j++) {
if (j != i && !vis[j]) {
dfs(j);
}
}
int deg[n];
for (int j = 0; j < n; j++) {
deg[j] = sz(graph[j]);
}
for (auto& a : graph[i]) {
deg[a]--;
}
deg[i] = 0;
if (*max_element(deg, deg + n) <= 2 && !bad) {
ans++;
} else {
dbg(i, bad);
}
}
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... |