1 /* 2 Name:hdoj-3342-Legal or Not 3 Copyright: 4 Author: 5 Date: 2018/4/11 15:59:18 6 Description: 7 判断是否存在环 8 */ 9 #include 10 #include 11 #include 12 #include 13 #include 14 using namespace std;15 const int MAXN = 1e+5;16 int du[MAXN], n , m, L[MAXN];17 vector g[MAXN];18 bool topsort() {19 memset(du, 0, sizeof(du));20 for (int i=0; i
Q;27 for (int i=0; i
>n>>m && (m || n)) {50 memset(L, 0, sizeof(L));51 memset(g, 0, sizeof(g));52 for (int i=0; i >a>>b;55 g[a].push_back(b);56 }57 if (topsort() == 1) cout<<"YES"<