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. 爬虫3:html页面+webdriver模块+demo

    保密性好的网站,不能使用request请求页面信息,这样可以使用webdriver模块先开启一个浏览器,然后爬去信息,甚至还可以click等操作对页面操作,再爬取. demo 一般流程: 1)包含se ...

  2. Git基本使用指南

    一.概述 1.    Git与SVN比较 目前用到最广泛的版本控制软件就是SVN和Git,那么这两者之间有什么不同之处呢? 1)     SVN(Subversion)是集中式管理的版本控制器,而Gi ...

  3. markdown数学公式大全

    目录 Cmd Markdown 公式指导手册 一.公式使用参考 1.如何插入公式 2.如何输入上下标 3.如何输入括号和分隔符 4.如何输入分数 5.如何输入开方 6.如何输入省略号 7.如何输入矢量 ...

  4. Bugku SQL注入2的思考

    网络安全初学者,欢迎评论交流学习,若内容中有错误欢迎各位指正. 题目地址:http://123.206.87.240:8007/web2/ 题目提示:都过滤了绝望吗?,提示 !,!=,=,+,-,^, ...

  5. 图像配准SIFT

    (一)图像特征匹配--SIFT 1.1 SIFT背景简介 SIFT算法是David Lowe在1999年提出的局部特征描述子,并在2004年深入发展和完善. SIFT算法是在尺度空间进行特征检测并确定 ...

  6. vue-cli2、vue-cli3脚手架详细讲解

    前言: vue脚手架指的是vue-cli它是vue官方提供的一个快速构建单页面(SPA)环境配置的工具,cli 就是(command-line-interface  ) 命令行界面 .vue-cli是 ...

  7. Linux对目录操作命令

    cd /home        进入 '/ home' 目录 cd ..        返回上一级目录 cd ../..        返回上两级目录 cd        进入个人的主目录 cd ~u ...

  8. javascript核心基础总结

    对<深入理解javascript原型和闭包系列>,<深入理解javascript系列>和<javascript深入系列>的学习总结 词法作用域 作用域就是,程序查找 ...

  9. django-Views之类视图 (六)

    book/urls.py from django.urls import path from . import views urlpatterns = [ path('',views.IndexVie ...

  10. 使用XPath

    XPath----XML路径语言 XPath概览 XPath是一门在XML文档中查找信息的语言,它提供了非常简洁明了的路径选择表达式. XPath常用规则 表达式 描  述 nodename 选取此节 ...