【HDU1530】【ZOJ1492】Maximum Clique
2016-09-25 23:04
155 查看
Position:
http://poj.org/problem?id=3241
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1492
http://poj.org/problem?id=3241
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1492
Description
大意:给了一个最多包含 50 个点的无向图,让求这个图中最大团所包含的的点的数量。Solution
Code
// <MaximumClique.cpp> - Mon Sep 19 20:59:48 2016 // This file is made by YJinpeng,created by XuYike's black technology automatically. // Copyright (C) 2016 ChangJun High School, Inc. // I don't know what this program is. #include <iostream> #include <vector> #include <algorithm> #include <cstring> #include <cstdio> #include <cstdlib> #include <cmath> #define MOD 1000000007 #define INF 1e9 using namespace std; typedef long long LL; const int MAXN=100010; const int MAXM=100010; inline int max(int &x,int &y) {return x>y?x:y;} inline int min(int &x,int &y) {return x<y?x:y;} inline int gi() { register int w=0,q=0;register char ch=getchar(); while((ch<'0'||ch>'9')&&ch!='-')ch=getchar(); if(ch=='-')q=1,ch=getchar(); while(ch>='0'&&ch<='9')w=w*10+ch-'0',ch=getchar(); return q?-w:w; } struct MAX_CLIQUE{ static const int N=60; bool G ; int n,Max ,Alt ,ans; bool DFS(int cur,int tot){ if(!cur){ if(tot>ans){ans=tot;return 1;} return 0; } for(int i=1;i<=cur;i++){ if(cur-i+tot+1<=ans)return 0; int u=Alt[tot][i],nxt=0; if(Max[u]+tot<=ans)return 0; for(int j=i+1;j<=cur;j++) if(G[u][Alt[tot][j]])Alt[tot+1][++nxt]=Alt[tot][j]; if(DFS(nxt,tot+1))return 1; } return 0; } int MaxClique(){ ans=0,memset(Max,0,sizeof(Max)); for(int i=n;i;i--){ int cur=0; for(int j=i+1;j<=n;j++) if(G[i][j])Alt[1][++cur]=j; DFS(cur,1); Max[i]=ans; } return ans; } void read(){ for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) G[i][j]=gi(); } }Group; int main() { freopen("MaximumClique.in","r",stdin); freopen("MaximumClique.out","w",stdout); while(Group.n=gi(),Group.n){ Group.read(); printf("%d\n",Group.MaxClique()); } return 0; }
相关文章推荐
- HDU1530 Maximum Clique & ZOJ 1492 Maximum Clique
- zoj1492 最大团
- ZOJ - 1492 dfs剪枝求最大团
- HDU1530:Maximum Clique(最大团)
- HDU1530 Maximum Clique (最大团)
- 【最大团】【HDU1530】【Maximum Clique】
- 【最大团】【HDU1530】【Maximum Clique】
- zoj 1338 || poj 1492 Up and Down Sequences
- zoj 1492 最大团顶点数量
- hdu1530 Maximum Clique(求最大团模板题)
- ZOJ 3681 ZJU2013年01月月赛F题 E - Cup 2
- zoj 2006 1729 字符串最小表示法 模板
- zoj 3735 概率dp
- ZOJ 3471 Most Powerful 状压dp
- ZOJ 1001 A + B Problem
- zoj Conquer a New Region 并查集
- zoj 3871 Convex Hull(凸包)
- ZOJ Problem Set - 1001
- zoj 1151 Word Reversal
- zoj 1337