当前位置:网站首页>HDU 1530 maximum clique
HDU 1530 maximum clique
2022-07-28 04:54:00 【gongyuandaye】
The question : Give an undirected graph , Find the knot number of the largest clique .
Answer key : The biggest group
group : If the picture is a group , Then the graph is undirected .
Great regiment : Not a subset of other groups .
The biggest group : The largest number of knots .
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<fstream>
#include<set>
#include<map>
#include<sstream>
#include<iomanip>
#define ll long long
#define pii pair<int, int>
using namespace std;
/* The biggest group = Make up a picture G The maximum number of independent sets of ———> Maximum number of independent sets = Make up a picture G' The biggest group */
// The largest group template
#define N 102
int mx;// Maximum number of cliques ( To initialize to 0)
int x[N], tuan[N];
int can[N][N];//can[i] Indicates that the selected i A point must be in the largest clique and may be added to the node set of the largest clique
int num[N];//num[i] Indicates by node i To the node n The number of knots of the largest group formed
bool g[N][N];// Adjacency matrix ( from 1 Start )
int n;
bool dfs(int tot, int cnt) {
int i, j, k;
if (tot == 0) {
if (cnt > mx) {
mx = cnt;
for (i = 0; i < mx; i++) {
tuan[i] = x[i];
}
return true;
}
return false;
}
for (i = 0; i < tot; i++) {
if (cnt + (tot - i) <= mx)return false;
if (cnt + num[can[cnt][i]] <= mx)return false;
k = 0;
x[cnt] = can[cnt][i];
for (j = i + 1; j < tot; j++) {
if (g[can[cnt][i]][can[cnt][j]]) {
can[cnt + 1][k++] = can[cnt][j];
}
}
if (dfs(k, cnt + 1))return false;
}
return false;
}
void MaxTuan() {
int i, j, k;
mx = 1;
for (i = n; i >= 1; i--) {
k = 0;
x[0] = i;
for (j = i + 1; j <= n; j++) {
if (g[i][j]) {
can[1][k++] = j;
}
}
dfs(k, 1);
num[i] = mx;
}
}
int main() {
while (scanf("%d", &n) && n) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
scanf("%d", &g[i][j]);
}
}
mx = 0;
MaxTuan();
printf("%d\n", num[1]);
}
return 0;
}
边栏推荐
- Service object creation and use
- flink思维导图
- 【sylar】框架篇-Chapter7-IO 协程调度模块
- Angr(十一)——官方文档(Part2)
- 外卖系统 文件上传
- App test process and test points
- np. unravel_ Index() finds the index value of an element (or group of elements) of the array after being pulled into one dimension. The corresponding index value in the original dimension (or specify
- How to quickly locate bugs? How to write test cases?
- Method of converting UI file to py file
- 物联网工业串口转WiFi模块 无线路由WiFi模块的选型
猜你喜欢

Array or object, date operation

The first artificial intelligence security competition starts. Three competition questions are waiting for you to fight

全方位分析STEAM和创客教育的差异化

UI automation test farewell from now on, manual download browser driver, recommended collection
![(3.1) [Trojan horse synthesis technology]](/img/e7/0e09c1d1bac23022ead7478ea9898a.png)
(3.1) [Trojan horse synthesis technology]
![[II. Mobile web page development] 2D & 3D conversion and animation, mobile terminal layout, responsive layout](/img/9a/a3b36aa2e5bf53d9f8355ea3c18f1e.png)
[II. Mobile web page development] 2D & 3D conversion and animation, mobile terminal layout, responsive layout

Dynamic SQL and paging

Introduction to this pointer

Mysql database -- first knowledge database

Interview fraud: there are companies that make money from interviews
随机推荐
np. The data returned from delete details is the data after deleting the specified dimension
pytorch打包exe出现WARNING: file already exists but should not: C:\Users\workAI\AppData\Local\Temp\_MEI13
What is the core value of testing?
(克隆虚拟机步骤)
(clone virtual machine steps)
【sylar】框架篇-Chapter23-模块篇总结
Take out system file upload
解析智能扫地机器人中蕴含的情感元素
Service object creation and use
Analyze the emotional elements contained in intelligent sweeping robot
Explain initialization list
[Oracle] 083 wrong question set
Gerrit operation - rollback a patch_ set
How to upgrade a pair of 12.2 RAC(primary) and a pair of 12.2 RAC(dataguard) to 19c
【sylar】框架篇-Chapter7-IO 协程调度模块
Improve the core quality of steam education among students
Depth traversal and breadth traversal of tree structure in JS
【sylar】框架篇-Chapter11-Socket 模块
动态sql和分页
[Sylar] framework Chapter 22 auxiliary module