#include #include #include using std::vector; using std::pair; void explore(int i, vector> &adj, int *state) { state[i] = 1; for(auto it2 : adj[i]) { if (state[it2] == 0) { explore(it2, adj,state); } if (state[it2] == 1) { std::cout<<"1"; exit(0); } } state[i] = 2; }; int acyclic(vector > &adj,size_t n) { //write your code here int state[n]; // permitted states are 0 1 and 2 // mark the states of all vertices initially to 0 for(int i=0;i> n >> m; vector > adj(n, vector()); for (size_t i = 0; i < m; i++) { int x, y; std::cin >> x >> y; adj[x - 1].push_back(y - 1); } acyclic(adj,n); }