Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.015 s | 4 KBi |
#2 |
Correcto
|
0.009 s | 4 KBi |
#3 |
Correcto
|
0.013 s | 3 KBi |
#4 |
Correcto
|
0.013 s | 3 KBi |
#5 |
Correcto
|
0.01 s | 4 KBi |
#6 |
Correcto
|
0.014 s | 3 KBi |
#7 |
Correcto
|
0.013 s | 3 KBi |
#8 |
Correcto
|
0.013 s | 4 KBi |
#9 |
Correcto
|
0.012 s | 4 KBi |
#10 |
Correcto
|
0.01 s | 4 KBi |
#11 |
Correcto
|
0.01 s | 4 KBi |
#12 |
Correcto
|
0.015 s | 4 KBi |
#13 |
Correcto
|
0.014 s | 4 KBi |
#14 |
Correcto
|
0.01 s | 4 KBi |
#15 |
Correcto
|
0.013 s | 4 KBi |
#16 |
Correcto
|
0.013 s | 4 KBi |
#17 |
Correcto
|
0.009 s | 4 KBi |
#18 |
Correcto
|
0.015 s | 4 KBi |
#19 |
Correcto
|
0.01 s | 4 KBi |
#20 |
Correcto
|
0.013 s | 4 KBi |
#21 |
Correcto
|
0.012 s | 4 KBi |
#22 |
Correcto
|
0.014 s | 3 KBi |
#23 |
Correcto
|
0.01 s | 4 KBi |
#24 |
Correcto
|
0.012 s | 4 KBi |
#25 |
Correcto
|
0.016 s | 4 KBi |
#26 |
Correcto
|
0.011 s | 4 KBi |
#27 |
Correcto
|
0.037 s | 4 KBi |
#28 |
Correcto
|
0.014 s | 3 KBi |
#29 |
Correcto
|
0.037 s | 4 KBi |
#30 |
Correcto
|
0.017 s | 4 KBi |
#31 |
Correcto
|
0.02 s | 3 KBi |
#32 |
Correcto
|
0.041 s | 5 KBi |
#33 |
Correcto
|
0.025 s | 5 KBi |
#34 |
Correcto
|
0.02 s | 4 KBi |
#35 |
Correcto
|
0.043 s | 5 KBi |
#include <bits/stdc++.h> #define fi first #define se second #define forn(i,n) for(int i=0; i< (int)n; ++i) #define for1(i,n) for(int i=1; i<= (int)n; ++i) #define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i) #define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i) #define fored(i,l,r) for(int i=(int)r; i>= (int)l; --i) #define pb push_back #define el '\n' #define d(x) cout<< #x<< " " << x<<el #define ri(n) scanf("%d",&n) #define sz(v) ((int)v.size()) #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() using namespace std; typedef long long ll; typedef double ld; typedef pair<int,int> ii; typedef pair<char,int> pci; typedef tuple<int, int, int> tiii; typedef pair<ll,ll> pll; typedef vector<int> vi; const int inf = 1e9; const int nax = 1e5+200; const ld pi = acos(-1); const ld eps= 1e-9; int dr[] = {1,-1,0, 0,1,-1,-1, 1}; int dc[] = {0, 0,1,-1,1, 1,-1,-1}; vi g[nax]; int seen[nax]; bool in[nax]; bool f = false; void dfs(int u, int c){ seen[u] = c; in[u] = true; for(int v : g[u]){ f |= (in[v]); if(!seen[v]){ dfs(v, c); } } in[u] = false; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout<< setprecision(20)<< fixed; int n, m; cin>> n>> m; int u, v; forn(i,m){ cin>> u>> v; g[u].pb(v); } forn(i,n){ if(!seen[i]){ dfs(i, i+1); } } cout<< (f ? "Yes" : "No")<<el; }