HDU1150 Machine Schedule

Source: Internet
Author: User

http://acm.hdu.edu.cn/showproblem.php?pid=1150

Minimum point overwrite = maximum match

Template questions

1#include <iostream>2#include <stdio.h>3#include <math.h>4#include <string.h>5#include <stdlib.h>6 using namespacestd;7 Const intn= the;8 intA[n][n];9 intUse[n];Ten intMatch[n]; One intn,m,k; A  - intDfsintu) - { the      for(intI=0; i<m;i++) -     { -         if(a[u][i]==1&&!use[i])//determine if contact and match have been made -         { +use[i]=1;//tag Matching -             if(match[i]==-1|| DFS (Match[i]))//if not matched, match +{//if it matches, force the match and backtrack to the last matched AMatch[i]=u;//machine, make other matches, if not, this match fails at                 return 1; -             } -         } -     } -     return 0; - } in intbipartite () - { to     intres=0; +memset (match,-1,sizeof(Match)); -      for(intI=0; i<n;i++) the     { *memset (use,0,sizeof(use)); $         if(Dfs (i))Panax Notoginsengres++; -     } the     returnRes; + } A intMain () the { +     //freopen ("In.txt", "R", stdin); -      while(~SCANF ("%d",&N)) $     { $         if(!N) -          Break; -         inth,p,q; theMemset (A,0,sizeof(a)); -scanf"%d%d",&m,&k);Wuyi          for(intI=0; i<k;i++) the         { -scanf"%d%d%d",&h,&p,&q); Wu             if(p>0&&q>0) -a[p][q]=1; About         } $         intt=bipartite (); -printf"%d\n", T); -     } -     return 0; A}

HDU1150 Machine Schedule

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.