Maximum Clique
Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5380    Accepted Submission(s): 2776
Problem Description
Given a graph G(V, E), a clique is a sub-graph g(v, e), so that for all vertex pairs v1, v2 in v, there exists an edge (v1, v2) in e. Maximum clique is the clique that has maximum number of vertex.
 
Input
Input contains multiple tests. For each test:
The first line has one integer n, the number of vertex. (1 < n <= 50)
The following n lines has n 0 or 1 each, indicating whether an edge exists between i (line number) and j (column number).
A test with n = 0 signals the end of input. This test should not be processed.
 
Output
One number for each test, the number of vertex in maximum clique.
 
Sample Input
5
0 1 1 0 1
1 0 1 1 1
1 1 0 1 1
0 1 1 0 1
1 1 1 1 0
0
 
Sample Output
4

C/C++:

 #include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <climits>
#include <iostream>
#include <algorithm>
#define INF 0xffffff
using namespace std;
const int my_max = ; int n, my_map[my_max][my_max], my_ans, my_set[my_max]; bool my_is_clique(int my_depth, int my_point)
{
for (int i = ; i < my_depth; ++ i)
if (!my_map[my_set[i]][my_point])
return false;
return true;
} void my_dfs(int my_depth, int my_point)
{
//if (my_depth + n - my_point + 1 <= my_ans) return;
for (int i = my_point; i <= n; ++ i)
{
if (my_is_clique(my_depth + , i))
{
my_set[my_depth + ] = i;
my_dfs(my_depth + , i + );
}
}
if (my_depth > my_ans) my_ans = my_depth;
} int main()
{
while (~scanf("%d", &n), n)
{
memset(my_map, , sizeof(my_map));
memset(my_set, , sizeof(my_set)); for (int i = ; i <= n; ++ i)
for (int j = ; j <= n; ++ j)
scanf("%d", &my_map[i][j]);
my_ans = ;
my_dfs(, );
printf("%d\n", my_ans);
}
return ;
}

hdu 1530 Maximum Clique (最大包)的更多相关文章

  1. hdu 1530 Maximum Clique

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1530 题目分类:最大团问题 DP + DFS 代码: #include<bits/stdc++. ...

  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. [CF85E] Guard Towers - 二分+二分图

    题目描述 In a far away kingdom lives a very greedy king. To defend his land, he built n n n guard towers ...

  2. 初识mpvue

    听说mpvue可以实现H5和小程序的同时开发  对使用过vue的选手几乎是0难度 忍不住搓搓小手手 看了文  唔~ 似乎不是很难的样子 然后实际上手操作了一下 老规矩:新建项目 npm install ...

  3. thinkcmf5 支付宝接口操作

    这是我自己摸索再结合网上搜索的一大堆内容搞出来的,官方的文件对于新手来说很难理解,什么文件放什么位置,该怎么引用,都要一一尝试,我这就直接列出来了,照样放就是了.同样适用于tp5,我这个也是tp5的 ...

  4. .NET Framework概述

    1.NET Framework是为其运行的应用程序提供各种服务的托管执行环境,它包括两个主要组件:(1).公共语言运行时 (CLR),(2)..NET Framework 类库: 2.NET Fram ...

  5. 拨云见日,彻底弄清楚Java日志框架 log4j, logback, slf4j的区别与联系

    log4j 以及 logback, slf4j 官网 日志框架的困惑 作为一个正常的项目,是必须有日志框架的存在的,没有日志,很难追踪一些奇奇怪怪的系统问题. 但是,我们经常在项目的依赖中,见到奇奇怪 ...

  6. js响应式布局

    <!DOCTYPE html> <html class="mobile"> <head> <meta charset="UTF- ...

  7. tomcat的虚拟路径的配置

    在一些项目中有时候需要把一些文件(例如图片.视频)存储在硬盘上的,如果是把文件在放在硬盘上的话,怎么才能访问到这些文件昵. 好了.下面就为大家讲讲如何利用tomcat 虚拟路径访问硬盘上的文件.总共有 ...

  8. ABP WebApi的请求类型

    Api对应的请求类型分为以下四种方法: 1.POST 2.PUT 3.DELETE 4.GET 一般abp的请求类型都是根据接口命名来定义的,Create——POST,Delete——DELETE,U ...

  9. 【已解决】ArcGIS Engine无法创建拓扑的问题(CreateTopology)

    也许,你的问题是这样的 ①System.Runtime.InteropServices.COMException:"未找到拓扑." ②myTopology结果是null,程序跳转到 ...

  10. Java对象的"后事处理"——垃圾回收(二)

    1 先谈Finalize() finalize()能做的所有工作,使用try-finally或者其他方式都可以做得更好.更及时,所以笔者建议大家完全可以忘掉Java语言中有这个方法的存在. ——< ...