Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.004 s | 3 KBi |
#2 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.004 s | 7 KBi |
#3 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.004 s | 11 KBi |
#4 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.004 s | 2 KBi |
#5 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.004 s | 3 KBi |
#6 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.005 s | 2 KBi |
#7 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.003 s | 7 KBi |
#8 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.005 s | 2 KBi |
#9 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.006 s | 4 KBi |
#10 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.003 s | 1 KBi |
#11 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.005 s | 4 KBi |
#12 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.003 s | 2 KBi |
#13 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.004 s | 1 KBi |
#14 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.003 s | 0 KBi |
#15 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.003 s | 15 KBi |
#16 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.005 s | 8 KBi |
#17 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.004 s | 15 KBi |
#18 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.005 s | 2 KBi |
#19 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.006 s | 1 KBi |
#20 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.004 s | 4 KBi |
#21 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.006 s | 2 KBi |
#22 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.004 s | 7 KBi |
#23 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.005 s | 2 KBi |
#24 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.004 s | 2 KBi |
#25 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.004 s | 7 KBi |
#26 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.007 s | 12 KBi |
#27 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.05 s | 3 KBi |
#28 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.005 s | 4 KBi |
#29 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.033 s | 3 KBi |
#30 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.005 s | 1 KBi |
#31 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.009 s | 2 KBi |
#32 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.035 s | 2 KBi |
#33 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.012 s | 5 KBi |
#34 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.014 s | 3 KBi |
#35 |
Correcto
main.cpp:39:24: warning: '&&' within '||' [-Wlogical-op-parentheses] if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ main.cpp:39:24: note: place parentheses around the '&&' expression to silence this warning if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) ^ ( ) 1 warning generated. |
0.039 s | 10 KBi |
#include <bits/stdc++.h> using namespace std; class Graph { int vertices; list<int> *adj; bool isCyclicUtil(int vertice, bool vertices[], bool *recursionStack); public: Graph(int vertices); void addEdge(int u, int v); bool isCyclic(); }; Graph::Graph(int vertices) { this->vertices = vertices; this->adj = new list<int>[vertices]; } void Graph::addEdge(int u, int v) { adj[u].push_back(v); } bool Graph::isCyclicUtil(int vertice, bool visited[], bool *recursionStack) { if (!visited[vertice]) { visited[vertice] = true; recursionStack[vertice] = true; list<int>::iterator i; for (i = adj[vertice].begin(); i != adj[vertice].end(); i++) { if (!visited[*i] && isCyclicUtil(*i, visited, recursionStack) || recursionStack[*i]) { return true; } } } recursionStack[vertice] = false; return false; } bool Graph::isCyclic() { bool *visited = new bool[vertices]; bool *recursionStack = new bool[vertices]; for (int i = 0; i < vertices; i++) { visited[i] = false; recursionStack[i] = false; } for (int i = 0; i < vertices; i++) { if (isCyclicUtil(i, visited, recursionStack)) { return true; } } return false; } int main() { int n, m, i; cin >> n; cin >> m; Graph g(n); for (i = 0; i < m; i++) { int u; int v; cin >> u; cin >> v; g.addEdge(u, v); } if (g.isCyclic()) { cout << "Yes"; } else { cout << "No"; } return 0; }