#ifndef EVAL
#include"grader.cpp"
#endif
#include<bits/stdc++.h>
using namespace std;
vector<int>g[5005];
bool on[5005],vis[5005];
int n,deg[5005];
bool dfs(int v,int p){
bool flag=false;
vis[v]=true;
for(int to:g[v])if(to!=p){
if(on[to])continue;
if(flag)return false;
if(vis[to])return false;
if(!dfs(to,v))return false;
flag=true;
}
return true;
}
bool check(){
for(int i=0;i<n;i++)vis[i]=0;
for(int i=0;i<n;i++)if(!on[i]&&!vis[i]&°[i]<2)if(!dfs(i,i))return false;
for(int i=0;i<n;i++)if(!vis[i]&&!on[i])return false;
return true;
}
void Init(int N){n=N;}
void Link(int x,int y){
g[x].push_back(y);
g[y].push_back(x);
deg[x]++;
deg[y]++;
}
int CountCritical(){
int cnt=0;
for(int i=0;i<n;i++){
on[i]=true;
for(auto to:g[i])deg[to]--;
cnt+=check();
for(auto to:g[i])deg[to]++;
on[i]=false;
}
return cnt;
}
/*
7 13
-1
1 2
-1
0 5
-1
2 0
-1
3 2
-1
3 5
-1
4 3
-1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
38 ms |
620 KB |
Output is correct |
3 |
Correct |
39 ms |
748 KB |
Output is correct |
4 |
Correct |
20 ms |
492 KB |
Output is correct |
5 |
Correct |
166 ms |
748 KB |
Output is correct |
6 |
Correct |
572 ms |
1024 KB |
Output is correct |
7 |
Correct |
17 ms |
492 KB |
Output is correct |
8 |
Correct |
96 ms |
748 KB |
Output is correct |
9 |
Correct |
370 ms |
876 KB |
Output is correct |
10 |
Correct |
384 ms |
876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
1004 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
38 ms |
620 KB |
Output is correct |
3 |
Correct |
39 ms |
748 KB |
Output is correct |
4 |
Correct |
20 ms |
492 KB |
Output is correct |
5 |
Correct |
166 ms |
748 KB |
Output is correct |
6 |
Correct |
572 ms |
1024 KB |
Output is correct |
7 |
Correct |
17 ms |
492 KB |
Output is correct |
8 |
Correct |
96 ms |
748 KB |
Output is correct |
9 |
Correct |
370 ms |
876 KB |
Output is correct |
10 |
Correct |
384 ms |
876 KB |
Output is correct |
11 |
Execution timed out |
4070 ms |
792 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
38 ms |
620 KB |
Output is correct |
3 |
Correct |
39 ms |
748 KB |
Output is correct |
4 |
Correct |
20 ms |
492 KB |
Output is correct |
5 |
Correct |
166 ms |
748 KB |
Output is correct |
6 |
Correct |
572 ms |
1024 KB |
Output is correct |
7 |
Correct |
17 ms |
492 KB |
Output is correct |
8 |
Correct |
96 ms |
748 KB |
Output is correct |
9 |
Correct |
370 ms |
876 KB |
Output is correct |
10 |
Correct |
384 ms |
876 KB |
Output is correct |
11 |
Execution timed out |
4070 ms |
792 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
38 ms |
620 KB |
Output is correct |
3 |
Correct |
39 ms |
748 KB |
Output is correct |
4 |
Correct |
20 ms |
492 KB |
Output is correct |
5 |
Correct |
166 ms |
748 KB |
Output is correct |
6 |
Correct |
572 ms |
1024 KB |
Output is correct |
7 |
Correct |
17 ms |
492 KB |
Output is correct |
8 |
Correct |
96 ms |
748 KB |
Output is correct |
9 |
Correct |
370 ms |
876 KB |
Output is correct |
10 |
Correct |
384 ms |
876 KB |
Output is correct |
11 |
Runtime error |
1 ms |
1004 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Halted |
0 ms |
0 KB |
- |