Topic Portal
1 /*2 Binary Graph Determination + point dyeing: Because there are a lot of unicom block, to all the points of the binary map matching, if not, there is no distribution of points, no3 each time a binary graph is matched, the collection of points is enlarged to the final first set .4 Note: n <= 1,no, two sets have at least one person; ans = = N, throw one to another set5 */6#include <cstdio>7#include <algorithm>8#include <cstring>9#include <cmath>Ten#include <string> One#include <vector> A#include <map> - using namespacestd; - the Const intMAXN = 1e5 +Ten; - Const intINF =0x3f3f3f3f; -vector<int>G[MAXN]; - intCOL[MAXN]; + intcnt[3]; - intN, M; + A BOOLDFS (intu) at { - for(intI=0; I<g[u].size (); ++i) - { - intv =G[u][i]; - if(Col[v] = =-1) { -COL[V] =3-Col[u]; cnt[col[v]]++; in if(! DFS (v))return false; - } to Else if(Col[v] = = Col[u])return false; + } - the return true; * } $ Panax Notoginseng voidWorkvoid) - { thememset (Col,-1,sizeof(col)); + intAns =0; A for(intI=1; i<=n; ++i) the { + if(Col[i] = =-1) - { $Col[i] =1; cnt[1] =1; cnt[2] =0; $ if(!DFS (i)) { -Puts ("Poor wyh");return ; - } theAns + = max (cnt[1], cnt[2]); - }Wuyi } the if(ans = = N) ans--; -printf ("%d%d\n", ans, N-ans); Wu } - About intMainvoid)//Bestcoder Round #48 ($) 1002 wyh2000 and pupil $ { - intT scanf ("%d", &t); - while(t--) - { Ascanf ("%d%d", &n, &m); + if(N <=1) { thePuts ("Poor wyh");Continue; - } $ for(intI=1; i<=n; ++i) g[i].clear (); the for(intI=1; i<=m; ++i) the { the intU, v; scanf ("%d%d", &u, &v); the G[u].push_back (v); G[v].push_back (u); - } in Work (); the } the About the return 0; the}
Binary graph determination + point dyeing bestcoder Round #48 ($) 1002 wyh2000 and pupil