#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 |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
314 ms |
596 KB |
Output is correct |
3 |
Correct |
516 ms |
596 KB |
Output is correct |
4 |
Correct |
15 ms |
464 KB |
Output is correct |
5 |
Correct |
168 ms |
616 KB |
Output is correct |
6 |
Correct |
521 ms |
844 KB |
Output is correct |
7 |
Correct |
117 ms |
468 KB |
Output is correct |
8 |
Correct |
271 ms |
596 KB |
Output is correct |
9 |
Correct |
502 ms |
724 KB |
Output is correct |
10 |
Correct |
480 ms |
668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
724 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
314 ms |
596 KB |
Output is correct |
3 |
Correct |
516 ms |
596 KB |
Output is correct |
4 |
Correct |
15 ms |
464 KB |
Output is correct |
5 |
Correct |
168 ms |
616 KB |
Output is correct |
6 |
Correct |
521 ms |
844 KB |
Output is correct |
7 |
Correct |
117 ms |
468 KB |
Output is correct |
8 |
Correct |
271 ms |
596 KB |
Output is correct |
9 |
Correct |
502 ms |
724 KB |
Output is correct |
10 |
Correct |
480 ms |
668 KB |
Output is correct |
11 |
Execution timed out |
4046 ms |
812 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
314 ms |
596 KB |
Output is correct |
3 |
Correct |
516 ms |
596 KB |
Output is correct |
4 |
Correct |
15 ms |
464 KB |
Output is correct |
5 |
Correct |
168 ms |
616 KB |
Output is correct |
6 |
Correct |
521 ms |
844 KB |
Output is correct |
7 |
Correct |
117 ms |
468 KB |
Output is correct |
8 |
Correct |
271 ms |
596 KB |
Output is correct |
9 |
Correct |
502 ms |
724 KB |
Output is correct |
10 |
Correct |
480 ms |
668 KB |
Output is correct |
11 |
Execution timed out |
4046 ms |
812 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
314 ms |
596 KB |
Output is correct |
3 |
Correct |
516 ms |
596 KB |
Output is correct |
4 |
Correct |
15 ms |
464 KB |
Output is correct |
5 |
Correct |
168 ms |
616 KB |
Output is correct |
6 |
Correct |
521 ms |
844 KB |
Output is correct |
7 |
Correct |
117 ms |
468 KB |
Output is correct |
8 |
Correct |
271 ms |
596 KB |
Output is correct |
9 |
Correct |
502 ms |
724 KB |
Output is correct |
10 |
Correct |
480 ms |
668 KB |
Output is correct |
11 |
Runtime error |
1 ms |
724 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |