poj_1466 Girls and Boys-Maximum independent set

Source: Internet
Author: User

Title: Find out who is not in love with each other.

Spit Groove: 500 points with the adjacency matrix of more than 4,000 MS, with the adjacency table 1000ms less than, so about 500 points should consider the adjacency table.

/************************************************author:D arktongcreated time:2016/7/31 20:12:30File Name: poj_1466.cpp*************************************************///#include <bits/stdc++.h>#include <cstring>#include<cstdio>#include<vector>using namespacestd;Const intMAXN = -+Ten; Vector<int>W[MAXN];intN, M;intLEFT[MAXN];BOOLUSED[MAXN];BOOLMatchintj) {     for(intI=0; I<w[j].size (); ++i)if(!Used[w[j][i]]) {        intv =W[j][i]; USED[V]=true; if(left[v]==-1||match (Left[v])) {Left[v]=J; return true; }    }    return false;}//returns the maximum number of matchesintHungary () {intres=0; Memset (left,-1,sizeof(left));  for(intI=0; i<m;++i) {memset (used,0,sizeof(used)); if(Match (i)) res++; }    returnRes;}intMain () {intT, cas=1;  while(SCANF ("%d", &n) = =1) {memset (W,0,sizeof(w)); M=N;  for(intI=0; i<n;++i) {intu, t, V; scanf ("%d: (%d)", &u, &t);  for(intj=0; j<t;++j) {scanf ("%d", &v);            W[u].push_back (v); }} printf ("%d\n", (2*n-hungary ()) >>1); }    return 0;}

poj_1466 Girls and Boys-Maximum independent set

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.