Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.012 s | 4 KBi |
#2 |
Correcto
|
0.012 s | 4 KBi |
#3 |
Correcto
|
0.015 s | 7 KBi |
#4 |
Correcto
|
0.015 s | 8 KBi |
#5 |
Correcto
|
0.015 s | 8 KBi |
#6 |
Correcto
|
0.017 s | 3 KBi |
#7 |
Correcto
|
0.011 s | 4 KBi |
#8 |
Correcto
|
0.019 s | 4 KBi |
#9 |
Correcto
|
0.015 s | 6 KBi |
#10 |
Correcto
|
0.016 s | 6 KBi |
#11 |
Correcto
|
0.015 s | 4 KBi |
#12 |
Correcto
|
0.011 s | 4 KBi |
#13 |
Correcto
|
0.016 s | 4 KBi |
#14 |
Correcto
|
0.017 s | 4 KBi |
#15 |
Correcto
|
0.012 s | 3 KBi |
#16 |
Correcto
|
0.017 s | 4 KBi |
#17 |
Correcto
|
0.013 s | 4 KBi |
#18 |
Correcto
|
0.014 s | 4 KBi |
#19 |
Correcto
|
0.018 s | 4 KBi |
#20 |
Correcto
|
0.013 s | 4 KBi |
#21 |
Correcto
|
0.014 s | 4 KBi |
#22 |
Correcto
|
0.017 s | 4 KBi |
#23 |
Correcto
|
0.012 s | 4 KBi |
#24 |
Correcto
|
0.019 s | 4 KBi |
#25 |
Correcto
|
0.014 s | 4 KBi |
#26 |
Correcto
|
0.344 s | 4 KBi |
#27 |
Tiempo límite excedido
|
1.04 s | 5 KBi |
#28 |
Correcto
|
0.333 s | 3 KBi |
#29 |
Tiempo límite excedido
|
1.067 s | 5 KBi |
#30 |
Correcto
|
0.324 s | 4 KBi |
#31 |
Correcto
|
0.351 s | 4 KBi |
#32 |
Correcto
|
0.041 s | 4 KBi |
#33 |
Correcto
|
0.018 s | 5 KBi |
#34 |
Tiempo límite excedido
|
1.081 s | 5 KBi |
#35 |
Correcto
|
0.042 s | 5 KBi |
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define pii pair<int, int> const int maxi = 1e5; vector<vector<int>>g(maxi); vector<int>vis(maxi); bool ok = false; void dfs(int u, int p){ vis[u] = 1; for(auto i: g[u]){ if(i==p){ ok = true; } if(!vis[i]){ dfs(i, p); } } } int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, m; cin>>n>>m; for(int i=0;i<m;i++){ int a, b; cin>>a>>b; g[a].push_back(b); } bool band = false; for(int i=0; i<n ;i++){ fill(vis.begin(), vis.begin()+n, 0); if(!vis[i]){ dfs(i, i); if(ok){ cout<<"Yes"<<endl; return 0; } } } cout<<"No"<<endl; return 0; }