分考场 蓝桥杯

#include <iostream>
using namespace std;
const int MAXV = 1000;
const int INF = 1000000000;

int n, G[MAXV][MAXV], res = INF, cun[MAXV][MAXV], cnt[MAXV] = {0};
bool vis[MAXV] = {false};

void DFS(int u, int depth)
{
if(depth >= res)
return;
if(u > n) {
res = depth;
return;
}
for(int i = 0; i < depth; i++) {
int len = cnt[i];
int c = 0;
for(int j = 0; j < len; j++) {
if(G[u][cun[i][j]] == INF)
c++;
}
if(c == len){
cun[i][cnt[i]++] = u;
DFS(u+1, depth);
cnt[i]--;
}
}
cun[depth][cnt[depth]++] = u;
DFS(u+1, depth+1);
cnt[depth]--;
}

int main()
{
int m, a, b;
cin >> n >> m;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
G[i][j] = G[j][i] = INF;
}
}
for(int i = 0; i < m; i++) {
cin >> a >> b;
G[a][b] = G[b][a] = 1;
}
DFS(1,0);
cout << res << endl;
return 0;
}

原文链接:https://blog.csdn.net/qys27182812/article/details/84311655?ops_request_misc=&request_id=7340b93fb4a4415685381caf416ca51e&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-21-84311655-null-null.268%5Ev1%5Econtrol&utm_term=%E6%91%A9%E6%89%98%E8%BD%A6%E8%80%83%E5%9C%BA

兔子先生 西安驾培

于灯火阑珊处,于暗香离别时,未曾放弃

相关推荐

抖音矩阵平台有哪些?

  抖音矩阵平台是指一系列用于在抖音平台上进行内容创作、运营和推广的工具和系统。其中,视界引擎短视频运营获客系统作为一款全面的抖音矩阵平台,具有许多优势。 抖音矩阵平台是当今数字营销领域的热门工 ...

怎么看待直播带货的营销形式?

随着电商行业的崛起,越来越多的商家开始使用直播的方式来进行产品推广,那么直播为什么可以推广产品带货呢?直播带货的本质是什么呢?今天,就来跟大家讲解一下。直播之所以可以推广产品,引导观众购买产品是因 ...

快抖矩阵多账号管理系统官方正版

账号源从哪里来?没有那么多抖音账号?怎么赚钱?有什么价值?       首先这是一套多开可招代理的矩阵账号管理系统,第一目的是让你拿来给有很多账号的品牌机构或达人当账号辅助管理工具打理账户 ...