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. java集合之HashSet哈希SET基础

    hashSet实现set接口.serializable.cloneable接口.不允许有重复值,但可以null,不保证与插入顺序一致. HashSet迭代的时间与HashSet实例的大小(元素的数量) ...

  2. 微信小程序——获取openGid

    小编使用的Node版本的解密方式(其他方式自行替换写法也是 一样的) 1.到微信小程序官网下载解密demo包 2.获取用户[openid] 3.调用 [wx.showShareMenu] 并且设置 w ...

  3. 百万年薪python之路 -- 包

    包 使用import 和from xx import xx 现有如下结构 bake ├── __init__.py ├── api ├── __init__.py ├── policy.py └── ...

  4. Gstreamer基础教程10 - Streaming

    摘要 我们把直接从网络播放一个媒体文件的方式称为在线播放(Online Streaming),我们已经在以往的例子中体验了GStreamer的在线播放功能,当我们指定播放URI为 http:// 时, ...

  5. Java TCP协议字节处理工具类

    1.使用 tcp 协议 读取 输入流的固定长度的字节数 public static byte[] getTcpSpecificBytes(BufferedInputStream bis,int len ...

  6. ssh终端远程登陆主机命令--笔记

    ssh终端远程登陆主机命令 ssh user@host ssh optadmin@10.55.45.38

  7. Ubuntu svn 安装 Rabbitvcs

    先添加源 sudo add-apt-repository ppa:rabbitvcs/ppa 必要的话在源清单里面也添加一下 sudo gedit /etc/apt/sources.list 内容是 ...

  8. java中Arrays.sort()对二位数组进行排序

    int [][]a = new int [5][2]; //定义一个二维数组,其中所包含的一维数组具有两个元素 对于一个已定义的二位数组a经行如下规则排序,首先按照每一个对应的一维数组第一个元素进行升 ...

  9. SpringBoot项目集成socketIo实现实时推送

    netty-socketio maven依赖 <dependency> <groupId>com.corundumstudio.socketio</groupId> ...

  10. 很详细很详细的gitLab使用具体流程

    gitLab详细流程 先说一下整个流程,就是先建立一个项目-----拆分里程碑-----拆分issue----项目开发-----项目总结---关闭里程碑 下面是每个步骤具体的步骤,这个比较适合那种纯新 ...