abc 310 d (dfs + 剪枝

#include 
using namespace std;
typedef long long ll;
typedef pair PII;
typedef pair PDD;
typedef vector VI;
const int mod = 1e8;
using ull = unsigned long long;
int n,m,t;
int hate[12];
int ta[12];
ll res = 0;
void dfs(int x){
    if(x>n){
        for(int i=1;i<=t;i++){
            if(ta[i] == 0) return;
        }
        res++;
        return;
    }
    for(int i=1;i<=t;i++){
        if((hate[x] & ta[i]) ==0){
            int tmp = ta[i];
            ta[i] |= (1<>n>>t>>m;
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        hate[a] |= 1 << b;
        hate[b] |= 1 << a;
    }
    dfs(1);
    cout<

 考虑将每个人必须放到一个组中,

同时有个重复型的剪枝,先保证前面的队伍是排好的

如果此人刚好放到了一个新的队伍中,那么他放到任何一个新的队伍中,都是等价的,

所以对于后面的新队伍,再把此人放进去是重复的,减掉

你可能感兴趣的:(搜索,算法,图论,深度优先)