#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int Ni = 1e6+5;
vector<int> edges[Ni];
int n, ans;
vector<int> p;
vector<int> sz;
int par(int u){
if(p[u] == u)return u;
return p[u] = par(p[u]);
}
bool IsSame(int u, int v){
return par(u) == par(v);
}
void merge(int u,int v){
u=par(u);v=par(v);
if(u == v)return;
p[v] = u;
sz[u] += sz[v];
return;
}
int have_this_number_of_edges[5];
void Init(int N_) {
n = N_;
ans = n;
p.assign(n,0);
sz.assign(n,0);
for(int i=0;i<n;i++)p[i] = i;
have_this_number_of_edges[0] = n;
}
int number_of_cycles;
void Link(int u, int v){
have_this_number_of_edges[min(4,(int)edges[u].size())]--;
have_this_number_of_edges[min(4,(int)edges[v].size())]--;
edges[u].pb(v);
edges[v].pb(u);
have_this_number_of_edges[min(4,(int)edges[u].size())]++;
have_this_number_of_edges[min(4,(int)edges[v].size())]++;
if(IsSame(u, v)){
number_of_cycles++;
}else {
merge(u,v);
}return;
}
int please_dont_go_there;
bool is_it_normal;
bool used[Ni];
void dfs(int u, int p){
used[u] = true;
int cnt= 0 ;
for(auto v : edges[u]){
if(v != please_dont_go_there)cnt++;
if(v == p || v == please_dont_go_there)continue;
if(used[v])is_it_normal = false;
else dfs(v,u);
}if(cnt>2)is_it_normal = false;
}
vector<int> cycle;
void PleaseFindCycles(int u, int p){
}
int CountCritical(){
if(number_of_cycles > 1 || have_this_number_of_edges[4] > 1)return 0;
if(!number_of_cycles && have_this_number_of_edges[4] == 1)return 1;
ans = 0;
for(int i=0;i<n;i++){
// it's like: what if we delete this vertex?
please_dont_go_there = i;
for(int j=0;j<n;j++)used[j] = false;
used[please_dont_go_there] = true;
is_it_normal = true;
for(int j=0;j<n;j++){
if(!used[j])dfs(j,j);
}
if(is_it_normal)ans++;
}return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
23828 KB |
Output is correct |
2 |
Correct |
20 ms |
24044 KB |
Output is correct |
3 |
Correct |
20 ms |
24140 KB |
Output is correct |
4 |
Correct |
38 ms |
24064 KB |
Output is correct |
5 |
Correct |
277 ms |
24044 KB |
Output is correct |
6 |
Correct |
768 ms |
24328 KB |
Output is correct |
7 |
Correct |
256 ms |
24076 KB |
Output is correct |
8 |
Correct |
23 ms |
24192 KB |
Output is correct |
9 |
Correct |
764 ms |
24188 KB |
Output is correct |
10 |
Correct |
879 ms |
24076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4085 ms |
44780 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
23828 KB |
Output is correct |
2 |
Correct |
20 ms |
24044 KB |
Output is correct |
3 |
Correct |
20 ms |
24140 KB |
Output is correct |
4 |
Correct |
38 ms |
24064 KB |
Output is correct |
5 |
Correct |
277 ms |
24044 KB |
Output is correct |
6 |
Correct |
768 ms |
24328 KB |
Output is correct |
7 |
Correct |
256 ms |
24076 KB |
Output is correct |
8 |
Correct |
23 ms |
24192 KB |
Output is correct |
9 |
Correct |
764 ms |
24188 KB |
Output is correct |
10 |
Correct |
879 ms |
24076 KB |
Output is correct |
11 |
Execution timed out |
4086 ms |
24004 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
23828 KB |
Output is correct |
2 |
Correct |
20 ms |
24044 KB |
Output is correct |
3 |
Correct |
20 ms |
24140 KB |
Output is correct |
4 |
Correct |
38 ms |
24064 KB |
Output is correct |
5 |
Correct |
277 ms |
24044 KB |
Output is correct |
6 |
Correct |
768 ms |
24328 KB |
Output is correct |
7 |
Correct |
256 ms |
24076 KB |
Output is correct |
8 |
Correct |
23 ms |
24192 KB |
Output is correct |
9 |
Correct |
764 ms |
24188 KB |
Output is correct |
10 |
Correct |
879 ms |
24076 KB |
Output is correct |
11 |
Execution timed out |
4086 ms |
24004 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
23828 KB |
Output is correct |
2 |
Correct |
20 ms |
24044 KB |
Output is correct |
3 |
Correct |
20 ms |
24140 KB |
Output is correct |
4 |
Correct |
38 ms |
24064 KB |
Output is correct |
5 |
Correct |
277 ms |
24044 KB |
Output is correct |
6 |
Correct |
768 ms |
24328 KB |
Output is correct |
7 |
Correct |
256 ms |
24076 KB |
Output is correct |
8 |
Correct |
23 ms |
24192 KB |
Output is correct |
9 |
Correct |
764 ms |
24188 KB |
Output is correct |
10 |
Correct |
879 ms |
24076 KB |
Output is correct |
11 |
Execution timed out |
4085 ms |
44780 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |