Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 3 KBi |
#2 |
Correcto
|
0.002 s | 2 KBi |
#3 |
Correcto
|
0.005 s | 11 KBi |
#4 |
Correcto
|
0.003 s | 0 KBi |
#5 |
Correcto
|
0.006 s | 13 KBi |
#6 |
Correcto
|
0.004 s | 6 KBi |
#7 |
Correcto
|
0.004 s | 1 KBi |
#8 |
Correcto
|
0.006 s | 17 KBi |
#9 |
Correcto
|
0.003 s | 4 KBi |
#10 |
Correcto
|
0.004 s | 2 KBi |
#11 |
Correcto
|
0.004 s | 2 KBi |
#12 |
Incorrecto
|
0.004 s | 3 KBi |
#13 |
Correcto
|
0.003 s | 3 KBi |
#14 |
Incorrecto
|
0.002 s | 3 KBi |
#15 |
Correcto
|
0.003 s | 5 KBi |
#16 |
Correcto
|
0.005 s | 7 KBi |
#17 |
Correcto
|
0.004 s | 1 KBi |
#18 |
Correcto
|
0.005 s | 11 KBi |
#19 |
Incorrecto
|
0.004 s | 1 KBi |
#20 |
Incorrecto
|
0.005 s | 8 KBi |
#21 |
Incorrecto
|
0.005 s | 7 KBi |
#22 |
Incorrecto
|
0.005 s | 9 KBi |
#23 |
Incorrecto
|
0.002 s | 7 KBi |
#24 |
Incorrecto
|
0.004 s | 1 KBi |
#25 |
Incorrecto
|
0.005 s | 9 KBi |
#26 |
Incorrecto
|
0.013 s | 5 KBi |
#27 |
Incorrecto
|
0.152 s | 5 KBi |
#28 |
Incorrecto
|
0.012 s | 3 KBi |
#29 |
Incorrecto
|
0.126 s | 7 KBi |
#30 |
Incorrecto
|
0.013 s | 2 KBi |
#31 |
Incorrecto
|
0.016 s | 1 KBi |
#32 |
Correcto
|
0.158 s | 13 KBi |
#33 |
Correcto
|
0.031 s | 6 KBi |
#34 |
Incorrecto
|
0.032 s | 2 KBi |
#35 |
Correcto
|
0.065 s | 5 KBi |
// #include <bits/stdc++.h> using namespace std; #define INF 1000000000 #define MOD 1000000007 #define PI 3.14159265 #define EPS 1e-9 #define Pi acos(-1.0) typedef pair<int, int> ii; typedef long long ll; typedef vector<ll> vll; typedef pair<ll,ll> pll; #define forr(i,a,b) for(int i=(a); i<(b); i++) #define clean(arr,val) memset(arr,val,sizeof(arr)) #define forn(i,n) forr(i,0,n) #define PB push_back typedef vector<int> vi; typedef vector<ii> vii; typedef vector<pll> vpll; /*CODE START HERE*/ int n, m; vector<vi> AdjList; bool ans, visited[10005]; map<ii,bool> appear; void bfs(int x){ queue<int> q; q.push(x); while(!q.empty()){ int u = q.front(); q.pop(); visited[u] = 1; for(int i = 0; i < (int)AdjList[u].size(); i++){ int v = AdjList[u][i]; if(visited[v]){ ans = true; }else{ q.push(v); } } } } int main(){ ios::sync_with_stdio(0); cin >> n >> m; AdjList.assign(n,vi()); int u, v; ans = false; appear.clear(); forn(i,m){ cin >> u >> v; ii temp = ii(u,v); if(appear.find(temp) == appear.end()){ appear[temp] = true; AdjList[u].push_back(v); } } clean(visited,0); forn(i,n){ if(!visited[i]){ bfs(i); } } if(ans){ cout << "Yes\n"; }else{ cout << "No\n"; } return 0; }