蓝桥杯 历届试题 分考场

//#include<bits/stdc++.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <functional>
#define sdddd(x,y,z,k) scanf("%d%d%d%d", &x, &y, &z, &k)
#define sddd(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define sdd(x,y) scanf("%d%d", &x, &y)
#define sd(x) scanf("%d", &x)
//#define mp make_pair
#define pb push_back
#define lson k<<1
#define rson k<<1|1
#define mid (l+r)/2
#define ms(x, y) memset(x, y, sizeof x)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 105;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int n, m, t;
int ta, tb;
int ans = INF;
int mp[maxn][maxn], cnt[maxn], f[maxn][maxn];
int vis[maxn];
void dfs(int x, int tot)
{
    if(tot >= ans)
        return;
    if(x > n)
    {
        ans = min(tot, ans);
        return;
    }
    for(int i = 1; i <= tot; i++)
    {
        int flag = 0;
        for(int j = 1; j <= cnt[i]; j++)
        {
            if(mp[x][f[i][j]])
            {
                flag = 1;
                break;
            }
        }
        if(flag == 0)
        {
            f[i][++cnt[i]] = x;
            dfs(x+1, tot);
            cnt[i]--;
        }
    }
    f[tot+1][++cnt[tot+1]] = x;
    dfs(x+1, tot+1);
    --cnt[tot+1];
}
int main()
{
    std::ios::sync_with_stdio(false);
	cin >> n >> m;
	while(m--)
    {
        cin >> ta >> tb;
        mp[ta][tb] = 1;
        mp[tb][ta] = 1;
    }
    dfs(1, 0);
    cout << ans << endl;

	return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值