当前位置:网站首页>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;
}
边栏推荐
- Mysql database -- first knowledge database
- NAT基本原理与私有IP
- What tools do software testers need to know?
- How to simulate common web application operations when using testcafe
- Web渗透之域名(子域名)收集方法
- FPGA: use PWM wave to control LED brightness
- What should testers know about login security?
- [Sylar] framework -chapter7-io coordination scheduling module
- 欧拉路/欧拉回路
- Depth traversal and breadth traversal of tree structure in JS
猜你喜欢

Inspire domestic students to learn robot programming education for children

CPU and memory usage are too high. How to modify RTSP round robin detection parameters to reduce server consumption?

Service object creation and use

解析智能扫地机器人中蕴含的情感元素

How to quickly locate bugs? How to write test cases?

驾驭EVM和XCM的强大功能,SubWallet如何赋能波卡和Moonbeam

字符串0123456789abcdef,子串(非空且非同串本身)的个数是多少【杭州多测师】【杭州多测师_王sir】...

Odoo action analysis (action.client, action.act_window, action.server)
![Geely AI interview question [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]](/img/18/27a86595eb3a7d30df359d6b2b8d8c.png)
Geely AI interview question [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]

Use and expansion of fault tolerance and fusing
随机推荐
Design and development of C language ATM system project
What tools do software testers need to know?
[Sylar] framework -chapter24- support business modularization
Chuangyuan will join hands with 50+ cloud native enterprises to explore new models to cross the digital divide
Phpstorm2022 connect to the database
Method of converting UI file to py file
100 lectures on Excel practical application cases (XI) - tips for inserting pictures in Excel
你必需要了解的saas架构设计?
Nat fundamentals and private IP
Automated test tool playwright (quick start)
[Sylar] framework -chapter12 bytearray module
Test report don't step on the pit
Jupyter notebook installation code prompt function
What SaaS architecture design do you need to know?
What is the core value of testing?
【sylar】框架篇-Chapter6-协程调度模块
printf()打印char* str
物联网工业串口转WiFi模块 无线路由WiFi模块的选型
System clock failure of database fault tolerance
[idea] check out master invalid path problem