hdu1530 Maximum Clique
来源:互联网 发布:魔法王座皇冠升级数据 编辑:程序博客网 时间:2024/05/22 17:38
Maximum Clique
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
最大团模板题
#include<bits/stdc++.h>using namespace std;const int maxn=51;int num[maxn];int G[maxn][maxn],ret;bool dfs(int *adj,int tot,int cnt){ if(tot==0){ if(cnt>ret){ ret=cnt; return 1; } return 0; } for(int i=0;i<tot;i++){ if(cnt+tot-i<=ret) continue; if(cnt+num[adj[i]]<=ret) continue; int t[maxn],k=0; for(int j=i+1;j<tot;j++){ if(G[adj[i]][adj[j]]) t[k ++] = adj[j]; } if(dfs(t,k,cnt+1)) return 1; } return 0;}void Maxclique(int n){ int adj[maxn],tot; for(int i=n;i>=1;i--){ tot=0; for(int j=i+1;j<=n;j++) if(G[i][j]==1) adj[tot++]=j; dfs(adj,tot,1); num[i]=ret; }}int main(){ int n; while(scanf("%d",&n)!=EOF){ if(n==0) break; memset(G,0,sizeof(G)); ret=0; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) scanf("%d",&G[i][j]); Maxclique(n); printf("%d\n",ret); } return 0;}
0 0
- hdu1530 Maximum Clique
- HDU1530 Maximum Clique & ZOJ 1492 Maximum Clique
- 【最大团】【HDU1530】【Maximum Clique】
- hdu1530 Maximum Clique,最大团 , DP,邻接矩阵
- HDU1530 Maximum Clique (最大团)
- HDU1530:Maximum Clique(最大团)
- hdu1530 Maximum Clique(求最大团模板题)
- hdu1530-回溯&最大团&菜鸟算法笔记-Maximum Clique
- Maximum Clique
- hdu 1530 Maximum Clique
- HDOJ 1530: Maximum Clique
- HDU 1530 Maximum Clique
- Greedy Algorithms and Maximum Clique
- Maximum Clique-最大团dfs
- Maximum Clique最大团问题
- 1530 Maximum Clique 最大团(模板)
- HDU 1530 Maximum Clique 图论最大团问题
- HDU ACM 1530 Maximum Clique->最大团
- 如何实现EDIUS中的素材的替换
- ubuntu发行版本
- 打电话、发邮件、发短信功能
- DevExpress源码编译报错解决办法
- 1045. Favorite Color Stripe (30)
- hdu1530 Maximum Clique
- 网络文件夹目前是以其他用户名和密码进行映射的——映射盘更换登录用户名问题
- AndFix 热补丁修复
- Google和百度搜索引擎为什么会成为世界第一和中国第一
- NSSortDescriptor使用注意以及直接排序字符串数组
- 小故事:架构师需要做什么?
- Jam的计数法
- QSS 常用网址
- PHP中include()与require()的区别说明