题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1530

题目分类:最大团问题 DP + DFS

代码:

#include<bits/stdc++.h>

using namespace std;
const int V=;
int g[V][V], dp[V], stk[V][V], mx;
int dfs(int n, int ns, int dep)
{
if ( == ns)
{
if (dep > mx) mx = dep;
return ;
}
int i, j, k, p, cnt;
for (i = ; i < ns; i++)
{
k = stk[dep][i]; cnt = ;
if (dep + n - k <= mx) return ;
if (dep + dp[k] <= mx) return ;
for (j = i + ; j < ns; j++)
{
p = stk[dep][j];
if (g[k][p]) stk[dep + ][cnt++] = p;
}
dfs(n, cnt, dep + );
}
return ;
} int clique(int n)
{
int i, j, ns;
for (mx = , i = n - ; i >= ; i--)
{
// vertex: 0 ~ n-1
for (ns = , j = i + ; j < n; j++)
if (g[i][j]) stk[][ ns++ ] = j;
dfs(n, ns, ); dp[i] = mx;
}
return mx;
} int main()
{
int n;
while(scanf("%d",&n)&&n)
{
for(int i=;i<n;i++)
{
for(int j=;j<n;j++)
{
scanf("%d",&g[i][j]);
}
}
int ans=clique(n);
printf("%d\n",ans);
}
return ;
}

hdu 1530 Maximum Clique的更多相关文章

  1. hdu 1530 Maximum Clique (最大包)

    Maximum CliqueTime Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  2. 【最大团】【HDU1530】【Maximum Clique】

    先上最大团定义: 最大团问题(Maximum Clique Problem, MCP)是图论中一个经典的组合优化问题,也是一类NP完全问题,在国际上已有广泛的研究,而国内对MCP问题的研究则还处于起步 ...

  3. Maximum Clique

    Maximum Clique Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...

  4. 回溯法——最大团问题(Maximum Clique Problem, MCP)

    概述: 最大团问题(Maximum Clique Problem, MCP)是图论中一个经典的组合优化问题,也是一类NP完全问题.最大团问题又称为最大独立集问题(Maximum Independent ...

  5. HDU 6047 - Maximum Sequence | 2017 Multi-University Training Contest 2

    /* HDU 6047 - Maximum Sequence [ 单调队列 ] 题意: 起初给出n个元素的数列 A[N], B[N] 对于 A[]的第N+K个元素,从B[N]中找出一个元素B[i],在 ...

  6. maximum clique 1

    maximum clique 1 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288KSpecial Judge, 64bit IO Format: % ...

  7. 2019牛客多校第五场 F maximum clique 1 状压dp+最大独立集

    maximum clique 1 题意 给出一个集合s,求每个子集的最大独立集的权值和(权值是独立集的点个数) 分析 n比较小,一股浓浓的暴力枚举每一个子集的感觉,但是暴力枚举模拟肯定会T,那么想一想 ...

  8. HDU 6047 Maximum Sequence(线段树)

    题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=6047 题目: Maximum Sequence Time Limit: 4000/2000 MS (J ...

  9. HDU 2459 Maximum repetition substring

    题目:Maximum repetition substring 链接:http://acm.hdu.edu.cn/showproblem.php?pid=2459 题意:给你一个字符串,求连续重复出现 ...

随机推荐

  1. 相邻数字的基数不等比:skew数

    2973:Skew数 描述在 skew binary表示中, 第 k 位的值xk表示xk*(2k+1-1). 每个位上的可能数字是0 或 1,最后面一个非零位可以是2, 例如, 10120(skew) ...

  2. 基于visual Studio2013解决C语言竞赛题之0907删除记录

       题目

  3. ADO.NET 对象 结构图

  4. IE 下使用firebug

    javascript :var firebug=document.createElement('script');firebug.setAttribute('src','http://getfireb ...

  5. windows下安装mysql5.6.13的主从复制

    如下操作均在vmware 虚拟机中winows xp 测试成功 中间走了很多弯路,网上的很多资料都是针对5.1以前的版本,在新版中根本无法使用,所以根据自己的实践整理了这篇文章 主服务:192.168 ...

  6. EasyUI - Slider组件

    效果: html代码: <input id="box" /> JS代码: $(function () { $('#box').slider({ width: ,//设置 ...

  7. 【linux】开发环境说明

    欢迎转载,转载时请保留作者信息,谢谢. 邮箱:tangzhongp@163.com 博客园地址:http://www.cnblogs.com/embedded-tzp Csdn博客地址:http:// ...

  8. File Templates for web.xml & web-fragment.xml (Servlet 2.3, 2.4, 2.5 + 3.0)

    As I sometimes need these, I have compiled a list of the valid headers of the web.xml and web-fragme ...

  9. ARC内存使用注意事项

    官方介绍: https://developer.apple.com/library/mac/#documentation/Performance/Conceptual/ManagingMemory/M ...

  10. python 默认编码( UnicodeDecodeError: 'ascii' codec can't decode)

    python在安装时,默认的编码是ascii,当程序中出现非ascii编码时,python的处理常常会报这样的错UnicodeDecodeError: 'ascii' codec can't deco ...