hdu6321 /// 状压DP
2024-09-03 11:59:31
题目大意:
将一个 顶点不重复的边 的边集称为图中的matching
在一个n个点的零图中进行m次操作
+ u v为在u v之间加一条边 存在重边
- u v为去掉u v之间的一条边
每次操作后 输出边集大小为1 2 3 ... n/2的有多少%(1e9+7)
https://www.cnblogs.com/xiuwenli/p/9398342.html
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define mem(i,j) memset(i,j,sizeof(i))
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,r,l) for(int i=r;i>=l;i--)
const int N=(<<)+;
const int mod=1e9+;
int n,m;
LL ans[+];
LL cnt[N],dp[N]; int main()
{
int _; scanf("%d",&_);
while(_--) {
scanf("%d%d",&n,&m);
int task=(<<)-;
inc(i,,task) cnt[i]=__builtin_popcount(i); // i二进制有多少1
mem(dp,); dp[]=1LL;
while(m--) {
char s[]; int u,v;
scanf("%s%d%d",s,&u,&v);
u--, v--;
int now=(<<u)|(<<v);
if(s[]=='+') {
inc(i,,task) if((i&now)==)
dp[i|now]=(dp[i|now]+dp[i])%mod;
} else {
inc(i,,task) if((i&now)==)
dp[i|now]=(dp[i|now]-dp[i]+mod)%mod;
}
mem(ans,);
inc(i,,task)
ans[cnt[i]]=(ans[cnt[i]]+dp[i])%mod;
inc(i,,n) {
printf("%lld",ans[i]);
if(i==n) printf("\n");
else printf(" ");
i++;
} // 边集为1对应2个点 2对应4个点 3对应6个点
}
} return ;
}
最新文章
- 使用Angular2理由
- MongoDB - 在Windows上安装
- 基于HtmlUnit的模板的网页数据抽取
- MVC 构造
- 证明:寝室分配问题是NPC问题
- 前自加(++a)与后自加(a++)的差别
- 你所不了解的float(滥用float的怪异现象) (转)
- linux安装和配置 mysql、redis 过程中遇到的问题记录(转)
- Python初探
- 找出共同好友 - 数据挖掘 - Scala版
- 学习 JavaScript(二)在 HTML 中使用 JS
- MySQL-mysql 8.0.11安装教程
- git 入门教程之 git 私服搭建教程
- Tuple Class
- numpy学习笔记.
- git入门(廖雪峰老师)
- [转帖]ASP.NET Core的Kestrel服务器
- 在nodejs中的集成虹软人脸识别
- STO单没有取进FP,IN_SAELS_ORDER表无,但IN_PO_STO有
- 使用FiddlerCore来截取替换Http请求中的网页内容