Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 1 KBi |
#2 |
Correcto
|
0.004 s | 8 KBi |
#3 |
Correcto
|
0.004 s | 2 KBi |
#4 |
Correcto
|
0.003 s | 2 KBi |
#5 |
Incorrecto
|
0.004 s | 2 KBi |
#6 |
Correcto
|
0.005 s | 2 KBi |
#7 |
Correcto
|
0.004 s | 2 KBi |
#8 |
Correcto
|
0.004 s | 2 KBi |
#9 |
Correcto
|
0.003 s | 2 KBi |
#10 |
Correcto
|
0.005 s | 2 KBi |
#11 |
Correcto
|
0.004 s | 61 KBi |
#12 |
Correcto
|
0.006 s | 2 KBi |
#13 |
Correcto
|
0.004 s | 2 KBi |
#14 |
Incorrecto
|
0.004 s | 2 KBi |
#15 |
Correcto
|
0.005 s | 2 KBi |
#16 |
Correcto
|
0.005 s | 3 KBi |
#17 |
Correcto
|
0.003 s | 2 KBi |
#18 |
Correcto
|
0.005 s | 2 KBi |
#19 |
Correcto
|
0.004 s | 4 KBi |
#20 |
Incorrecto
|
0.005 s | 2 KBi |
#21 |
Incorrecto
|
0.005 s | 2 KBi |
#22 |
Correcto
|
0.005 s | 2 KBi |
#23 |
Incorrecto
|
0.004 s | 4 KBi |
#24 |
Incorrecto
|
0.005 s | 2 KBi |
#25 |
Incorrecto
|
0.005 s | 2 KBi |
#26 |
Correcto
|
0.015 s | 2 KBi |
#27 |
Incorrecto
|
0.032 s | 2 KBi |
#28 |
Correcto
|
0.02 s | 3 KBi |
#29 |
Incorrecto
|
0.03 s | 2 KBi |
#30 |
Correcto
|
0.019 s | 6 KBi |
#31 |
Correcto
|
0.02 s | 13 KBi |
#32 |
Correcto
|
0.042 s | 2 KBi |
#33 |
Correcto
|
0.014 s | 4 KBi |
#34 |
Tiempo límite excedido
|
1.04 s | 2 KBi |
#35 |
Correcto
|
0.035 s | 2 KBi |
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <queue> #include <set> #include <map> #include <vector> #include <stack> #include <algorithm> #define forn(a, n) for(int a = 0; a<(int) (n); ++a) #define rforn(a, n) for(int a = (n)-1; a>=0; --a) using namespace std; const int N = 6e5+20; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int nodos; int aristas; int desde; int hasta; int este; string res = "No"; cin>>nodos>>aristas; vector < vector<int> > ady; bool probados [10000]= {false}; for(int k = 0; k < nodos; k++) { vector<int> vacia; ady.push_back(vacia); } for(int k = 0; k < aristas; k++) { cin>>desde>>hasta; ady[desde].push_back(hasta); } /*for(int k = 0; k < aristas; k++) { for(int i = 0; i < ady[k].size(); i++) cout<<ady[k][i]<<" - "; cout<<endl; }*/ /// for(int k = 0; k < nodos; k++) { bool visitados [10000] = {false}; bool done [10000] = {false}; stack <int> q; q.push(k); while(!q.empty()) { este = q.top(); q.pop(); if(visitados[este]==true && done[este]==false) { res = "Yes"; break; } visitados[este] = true; if(ady[este].size() == 0) done[este] = true; for(int i = 0; i < ady[este].size(); i++) { q.push(ady[este][i]); } } if(res=="Yes") break; } cout<<res<<endl; }