Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 2 KBi |
#2 |
Correcto
|
0.006 s | 2 KBi |
#3 |
Correcto
|
0.007 s | 2 KBi |
#4 |
Correcto
|
0.006 s | 2 KBi |
#5 |
Correcto
|
0.007 s | 3 KBi |
#6 |
Correcto
|
0.006 s | 2 KBi |
#7 |
Correcto
|
0.006 s | 2 KBi |
#8 |
Correcto
|
0.015 s | 2 KBi |
#9 |
Correcto
|
0.017 s | 2 KBi |
#10 |
Correcto
|
0.011 s | 2 KBi |
#11 |
Correcto
|
0.01 s | 2 KBi |
#12 |
Correcto
|
0.027 s | 3 KBi |
#13 |
Correcto
|
0.006 s | 1 KBi |
#14 |
Correcto
|
0.007 s | 2 KBi |
#15 |
Correcto
|
0.006 s | 2 KBi |
#16 |
Correcto
|
0.005 s | 2 KBi |
#17 |
Correcto
|
0.01 s | 2 KBi |
#18 |
Correcto
|
0.005 s | 1 KBi |
#19 |
Correcto
|
0.005 s | 2 KBi |
#20 |
Correcto
|
0.007 s | 2 KBi |
#21 |
Correcto
|
0.005 s | 1 KBi |
#22 |
Correcto
|
0.009 s | 3 KBi |
#23 |
Correcto
|
0.006 s | 2 KBi |
#24 |
Correcto
|
0.006 s | 2 KBi |
#25 |
Correcto
|
0.005 s | 2 KBi |
#26 |
Correcto
|
0.023 s | 6 KBi |
#27 |
Correcto
|
0.064 s | 3 KBi |
#28 |
Correcto
|
0.007 s | 2 KBi |
#29 |
Correcto
|
0.056 s | 3 KBi |
#30 |
Correcto
|
0.006 s | 2 KBi |
#31 |
Correcto
|
0.008 s | 1 KBi |
#32 |
Correcto
|
0.038 s | 4 KBi |
#33 |
Correcto
|
0.046 s | 3 KBi |
#34 |
Correcto
|
0.017 s | 2 KBi |
#35 |
Correcto
|
0.025 s | 3 KBi |
/// Write by Daniel Perez .PERAPRO #include<bits/stdc++.h> using namespace std; #define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define pb push_back #define ff first #define ss second typedef long long ll; typedef unsigned long long ull; typedef long double ld; using vi=vector<int>; using vl=vector<ll>; using pii=pair<int,int>; char el = '\n'; char esp = ' '; template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } ostream& operator<<(ostream& os, const vector<int> &v){ for(auto const &i: v){ os<<i<<" "; } os<<'\n'; return os; } string yes="Yes"; string no="No"; const int N=1e4+5; set<int> g[N]; int color[N]; int n,m; int cycle_start, cycle_end; bool dfs(int v){ color[v]=1; for(int u:g[v]){ if(!color[u]){ if(dfs(u)) return 1; }else if(color[u] == 1){ return 1; } } color[v] =2; return 0; } int main(){ fast_io; /* freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); */ int a,b; cin>>n>>m; bool f=0; for(int i=0;i<m;i++){ cin>>a>>b; f|=(a == b); g[a].insert(b); } for(int i=0;i<n;i++){ if(color[i] == 0 && dfs(i)) f=1; } if(f) cout<<yes<<el; else cout<<no<<el; } /* */