1530 Maximum Clique 最大团(模板)
来源:互联网 发布:淘宝店一颗心 编辑:程序博客网 时间:2024/06/05 19:27
点击打开链接
Maximum Clique
Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2107 Accepted Submission(s): 1117
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.
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
50 1 1 0 11 0 1 1 11 1 0 1 10 1 1 0 11 1 1 1 00
Sample Output
4
Author
CHENG, Long
Source
ZOJ Monthly, February 2003
Recommend
mcqsmall
最大团的模板题。详细解释:点击打开链接。
#include<stdio.h>#define M 51int g[M][M],cs[M],ans[M],now[M];int re;bool flag;//最大团模板//////////////////////////////void dfs(int n,int depth,int *u){ int i,j,k,v[M],vn; if(n) { if(depth+cs[u[0]]<=re) return; for(i=0;i<n+depth-re;i++) { for(j=i+1,vn=0;j<n;j++) if(g[u[i]][u[j]]) v[vn++]=u[j]; now[depth]=u[i]; dfs(vn,depth+1,v); if(flag) return; } } else if(depth>re) { re=depth; flag=true; for(i=0;i<depth;i++) ans[i]=now[i]; }}int clique(int n){ int vn,v[M],i,j,k; re=0; for(cs[i=n-1];i>=0;i--) { for(vn=0,j=i+1;j<n;j++) if(g[i][j]) v[vn++]=j; flag=false; now[0]=i; dfs(vn,1,v); cs[i]=re; } return re;}//////////////////////////////////////int main(){ int n; while(scanf("%d",&n),n) { for(int i=0;i<n;i++) for(int j=0;j<n;j++) scanf("%d",&g[i][j]); printf("%d\n",clique(n)); } return 0;}
- 1530 Maximum Clique 最大团(模板)
- HDOJ 1530 Maximum Clique(最大团模板题)
- hdoj--1530--Maximum Clique(最大团)
- HDU 1530 Maximum Clique 简单的最大团模板题
- [HDU]1530 Maximum Clique 最大团问题[模板]
- hdu1530 Maximum Clique(求最大团模板题)
- hdu 1530 Maximum Clique(最大团模版)
- HDU ACM 1530 Maximum Clique->最大团
- [HDU 1530] Maximum Clique 最大团
- hdoj 1530 Maximum Clique 【最大团】
- HDU 1530 Maximum Clique 最大团
- hdu-1530-Maximum Clique-找最大团
- 最大团算法(Maximum Clique)
- HDU1530 Maximum Clique (最大团)
- HDU1530:Maximum Clique(最大团)
- Maximum Clique-最大团dfs
- 【最大团】【HDU1530】【Maximum Clique】
- Maximum Clique最大团问题
- Uva11549 模拟判断有环的问题 Floyd判圈算法
- android笔记
- Windows 7中安装SQL2005提示IIS未安装 解决办法 .
- 开源Word读写组件DocX,通过word模板,导出用户简历使用示例
- 【笔记】【环境搭建】Ubuntu下使用STLPort
- 1530 Maximum Clique 最大团(模板)
- SQL语句的增删改查(详细)
- 大话设计模式七:代理模式(proxy)
- 从一组无序的整数中找出前N大的数
- centos 安装svn server( http https )
- Cannot open include file: 'fstream.h': No such file or directory
- Javascript中最常用的125个经典技巧
- 字符串的最大回文子串判断
- 基于openswan klips的IPsec VPN实现分析(一)数据发送