Test instructions: give n worms, then A and b mate, give m to a and B and ask if there are any gay worms
Link: Point Me
It's like a gangster's problem.
1#include <stdio.h>2#include <algorithm>3#include <iostream>4#include <string.h>5 using namespacestd;6 Const intmaxn= .;7 intF[MAXN];8 intVAL[MAXN];9 intFindintx)Ten { One if(f[x]==-1)returnx; A inttmp=find (F[x]); -val[x]+=Val[f[x]]; -val[x]%=2; Update the offset of a child node (that is, the gender of the relative root) the returnf[x]=tmp; - } - intMain () - { + intT; - intn,m; +scanf"%d",&T); A intIcase=0; at while(t--) - { -icase++; -memset (f,-1,sizeof(F)); -Memset (Val,0,sizeof(Val)); -scanf"%d%d",&n,&m); in BOOLflag=true; - intu,v; to while(m--) + { -scanf"%d%d",&u,&v); the if(!flag)Continue; * intT1=find (u), t2=Find (v); $ if(t1==T2)Panax Notoginseng { - if(Val[u]==val[v]) flag=false; the } + Else A { thef[t1]=T2; +val[t1]=val[v]-val[u]+1; -val[t1]%=2; Not belong to the same collection, the key step, think for a long time, turned out to be the default gender difference $ } $ } - if(flag) printf ("Scenario #%d:\nno Suspicious bugs found!\n\n", icase); - Elseprintf"Scenario #%d:\nsuspicious Bugs found!\n\n", icase); the } - return 0;Wuyi}
Poj 2492 and look up the set