Binary graph determination + point dyeing bestcoder Round #48 ($) 1002 wyh2000 and pupil

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.