#include <bits/stdc++.h>
using namespace std;
const int k_N = 1e6 + 3;
int n;
int p[k_N], sz[k_N];
vector<int> adj[k_N];
int deg[k_N];
int cnt[k_N], req;
bool ok;
int get_p(int u){
if(p[u] == u) return u;
return p[u] = get_p(p[u]);
}
bool unite(int u, int v){
if(get_p(u) == get_p(v))
return false;
if(sz[p[u]] < sz[p[v]])
swap(u, v);
sz[p[u]] += sz[p[v]];
p[p[v]] = p[u];
return true;
}
void Init(int n_){
n = n_;
for(int i = 0; i < n; ++i){
p[i] = i;
sz[i] = 1;
deg[i] = 0;
cnt[i] = 0;
}
req = 0;
ok = true;
}
bool dfs(int a, int b, int parent = -1){
if(a == b){
cnt[a]++;
return true;
}
for(int to: adj[a]){
if(to == parent) continue;
if(dfs(to, b, a)){
cnt[a]++;
return true;
}
}
return false;
}
void Link(int a, int b){
deg[a]++;
deg[b]++;
if(deg[a] >= 4 || deg[b] >= 4) ok = false;
if(!unite(a, b)){
req++;
dfs(a, b);
}
else{
adj[a].push_back(b);
adj[b].push_back(a);
}
}
int CountCritical(){
if(!ok) return 0;
int ans = 0;
for(int i = 0; i < n; ++i)
ans += cnt[i] == req;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
23808 KB |
Output is correct |
2 |
Incorrect |
17 ms |
24064 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
464 ms |
55272 KB |
Output is correct |
2 |
Incorrect |
1110 ms |
72056 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
23808 KB |
Output is correct |
2 |
Incorrect |
17 ms |
24064 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
23808 KB |
Output is correct |
2 |
Incorrect |
17 ms |
24064 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
23808 KB |
Output is correct |
2 |
Incorrect |
17 ms |
24064 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |