题目链接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. Java基础:多态(重载和重写)

    转载请注明出处:jiq•钦's technical Blog (1)域与静态方法 记住"仅仅有普通方法的调用是多态的". 而域和静态方法不是:对于域的訪问.在编译期间就已经进行解析 ...

  2. Android ListView 常见问题与使用总结

    一.机制 ListView机制 - 先运行getCount.然后运行getView. 假设getCount返回0,不运行getView Gallery convertView不会复用.每次都返回NUL ...

  3. SqlServer数据库存储过程的使用

    搞开发这么久了,说实话很少用到存储过程,大部分代码都在业务层给处理了. 今天在做APP接口的时候,表里面没有数据,需要模拟一些数据,于是就想到存储过程,来一起用下吧. SqlServer中创建存储过程 ...

  4. [Oracle]TRIGGER

    题外话: Oracle 的使用. 以前客户方用的是SQL SERVER,一直在用SQL SERVER,感觉SQL SERVER的用户体验非常好. 不管是开发环境的界面布局到SQL 的写法上,感觉写起来 ...

  5. opencv之haar特征+AdaBoos分类器算法流程(二)

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...

  6. 【linux】linux根文件系统制作

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

  7. C# webBrowser操作 javascript

    using System; using System.Windows.Forms; namespace Demo { public partial class Form1 : Form { publi ...

  8. 快速安装多系统(xp与win7)

    具体方法: 1.利用pe安装xp系统 2.xp下,空出一个分区,用于安装win7 3.进入pe下,安装win7系统到空出的分区 4.win7正常启动后,会覆盖原来xp的启动方式 5.再次进入pe,利用 ...

  9. SRM 627 D1L2GraphInversionsDFS查找指定长度的所有路径 Binary indexed tree (BIT)

    题目:http://community.topcoder.com/stat?c=problem_statement&pm=13275&rd=16008 由于图中边数不多,选择DFS遍历 ...

  10. MSSQL - 自增1的标识列一次增长了1000

    @情若天_RunUp: 1. Open "SQL Server Configuration Manager"2. Click "SQL Server Services&q ...