zoukankan      html  css  js  c++  java
  • poj3692

    题解:

    对于每两个不认识的建边

    然后求最大都立集

    代码:

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<cmath>
    using namespace std;
    const int N=205;
    int n,m,k,a[N][N],match[N],f[N],x,y,cas;
    int dfs(int x)
    {
        for (int i=1;i<=m;i++)
         if (!a[x][i]&&!f[i])
          {
              f[i]=1;
              if (!match[i]||dfs(match[i]))
               {
                   match[i]=x;
                   return 1;
               }
          }
        return 0;  
    }
    int main()
    {
        while (~scanf("%d%d%d",&n,&m,&k),n||m||k)
         {
             memset(a,0,sizeof a);
             printf("Case %d: ",++cas);
             memset(match,0,sizeof match);
             while (k--)scanf("%d%d",&x,&y),a[x][y]=1;
             int ans=0;
             for (int i=1;i<=n;i++)
              {
                  memset(f,0,sizeof f);
                  ans+=dfs(i);
              }
             printf("%d
    ",n+m-ans);
         }
    }
  • 相关阅读:
    Go
    Go
    Go
    Go
    Go
    Go
    爬虫常用相关库
    Go
    python基础第7天(day19)
    python基础第五天(day17)元组,集合,字符串操作 字符编码:
  • 原文地址:https://www.cnblogs.com/xuanyiming/p/8259889.html
Copyright © 2011-2022 走看看