#pragma comment(linker, "/STACK:102400000,102400000") #include #include #include #include #include #include using namespace std; const int maxn=1000005; stack S; typedef struct Edge { int s,e; Edge(int s=0,int e=0):s(s),e(e){} }Edge; Edge E1[maxn],E2[maxn]; //强连通分量 int dfn[maxn],n,low[maxn],cid[maxn],max_size,m1,m2,c; bool v[maxn]; int f[maxn]; int head[maxn],nxt[maxn]; void init() { memset(head,-1,sizeof(nxt)); memset(dfn,0,sizeof(dfn)); memset(low,0,sizeof(low)); memset(v,0,sizeof(v)); memset(f,-1,sizeof(f)); max_size=0; c=0; while(!S.empty()) S.pop(); } void Tayjan(int x) { dfn[x]=low[x]=++c; S.push(x); v[x]=1; for(int i=head[x];i!=-1;i=nxt[i]) { int a=E2[i].e; if(!dfn[a]) { Tayjan(a); low[x]=min(low[x],low[a]); } else if(v[a]) low[x]=min(low[x],dfn[a]); } if(dfn[x]==low[x]) { max_size++; int a; do{ a=S.top(); S.pop(); cid[a]=max_size; v[a]=0; }while(a!=x); } } bool judge() {//有向边是否构成环 for(int i=1;i<=n;i++) if(!dfn[i]) Tayjan(i); return max_size>t; bool ok; int cnt; while(t--) { scanf("%d%d%d",&n,&m1,&m2); cnt=0; ok=0; init(); input(); if(judge()){printf("YES\n");continue;} for(int i=0;i