#include "bits/stdc++.h"
using namespace std;
long long n;
vector< vector<long long> > Grafo;
vector<long long> Visitados;
void Init(int N_) {
n = (long long)N_;
Grafo.assign(n, vector<long long>());
}
void Link(int A, int B){
long long a = (long long)A;
long long b = (long long)B;
Grafo[a].push_back(b);
Grafo[b].push_back(a);
}
int Bien;
void DFS(long long Nodo, long long Anterior){
Visitados[Nodo] = 1;
long long c = 0;
for(auto E: Grafo[Nodo]){
if(Visitados[E] == 1) c++;
if(Visitados[E] == 1 and E != Anterior){
if(Bien != 0){
//cout<<"Ciclo //"<<Nodo<<" "<<E<<" "<<Anterior<<" "<<Visitados[E]<<"// ";
}
Bien = 0;
}
if(Visitados[E] == 0){
DFS(E, Nodo);
c++;
}
}
if(c >= 3){
if(Bien != 0){
//cout<<"Vecinos salgan\n";
}
Bien = 0;
}
}
int CountCritical(){
int r = 0;
for(long long i = 0; i < n; i++){
Bien = 1;
Visitados.assign(n, 0);
Visitados[i] = 2;
for(long long j = 0; j < n; j++){
if(i == j) continue;
/*for(auto E: Visitados) cout<<E<<" ";
cout<<"\n";*/
if(Visitados[j] == 0){
DFS(j, -2);
//cout<<j<<" ";
}
//cout<<"\n\n";
/*cout<<j<<" ";
for(auto E: Grafo[j]) cout<<E<<" ";
cout<<"\n";*/
}
r += Bien;
}
//cout<<"Respuesta: ";
return r;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
239 ms |
764 KB |
Output is correct |
3 |
Correct |
391 ms |
848 KB |
Output is correct |
4 |
Correct |
13 ms |
336 KB |
Output is correct |
5 |
Correct |
112 ms |
732 KB |
Output is correct |
6 |
Correct |
483 ms |
992 KB |
Output is correct |
7 |
Correct |
102 ms |
592 KB |
Output is correct |
8 |
Correct |
243 ms |
592 KB |
Output is correct |
9 |
Correct |
433 ms |
888 KB |
Output is correct |
10 |
Correct |
416 ms |
848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4070 ms |
39752 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
239 ms |
764 KB |
Output is correct |
3 |
Correct |
391 ms |
848 KB |
Output is correct |
4 |
Correct |
13 ms |
336 KB |
Output is correct |
5 |
Correct |
112 ms |
732 KB |
Output is correct |
6 |
Correct |
483 ms |
992 KB |
Output is correct |
7 |
Correct |
102 ms |
592 KB |
Output is correct |
8 |
Correct |
243 ms |
592 KB |
Output is correct |
9 |
Correct |
433 ms |
888 KB |
Output is correct |
10 |
Correct |
416 ms |
848 KB |
Output is correct |
11 |
Execution timed out |
4054 ms |
724 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
239 ms |
764 KB |
Output is correct |
3 |
Correct |
391 ms |
848 KB |
Output is correct |
4 |
Correct |
13 ms |
336 KB |
Output is correct |
5 |
Correct |
112 ms |
732 KB |
Output is correct |
6 |
Correct |
483 ms |
992 KB |
Output is correct |
7 |
Correct |
102 ms |
592 KB |
Output is correct |
8 |
Correct |
243 ms |
592 KB |
Output is correct |
9 |
Correct |
433 ms |
888 KB |
Output is correct |
10 |
Correct |
416 ms |
848 KB |
Output is correct |
11 |
Execution timed out |
4054 ms |
724 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
239 ms |
764 KB |
Output is correct |
3 |
Correct |
391 ms |
848 KB |
Output is correct |
4 |
Correct |
13 ms |
336 KB |
Output is correct |
5 |
Correct |
112 ms |
732 KB |
Output is correct |
6 |
Correct |
483 ms |
992 KB |
Output is correct |
7 |
Correct |
102 ms |
592 KB |
Output is correct |
8 |
Correct |
243 ms |
592 KB |
Output is correct |
9 |
Correct |
433 ms |
888 KB |
Output is correct |
10 |
Correct |
416 ms |
848 KB |
Output is correct |
11 |
Execution timed out |
4070 ms |
39752 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |