[CF903]Party

Party

题解

看见n\leq 22,很容易想到状压。

dp_{i}表示说有互相认识的人状态为i时,集合i中的每个人都认识集合中的其他人。

于是,转移方程式就很好想了,dp_{s|a_{i}}=min \left \{ dp_{s}+1 \right \}

依次更新一遍就可以了。

源码

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF=0x7f7f7f7f;
const int mo=1e9+7;
typedef pair<LL,LL> pii;
int n,m,a[25],dp[(1<<22)+5],q[(1<<22)+5],f[(1<<22)+5];
void solve(int s){if(f[s])solve(f[s]);printf("%d ",q[s]);}
sig
posted @ 2020-08-09 16:44  StaroForgin  阅读(7)  评论(0)    收藏  举报  来源