题目大意:

将一个 顶点不重复的边 的边集称为图中的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 ;
}

最新文章

  1. 使用Angular2理由
  2. MongoDB - 在Windows上安装
  3. 基于HtmlUnit的模板的网页数据抽取
  4. MVC 构造
  5. 证明:寝室分配问题是NPC问题
  6. 前自加(++a)与后自加(a++)的差别
  7. 你所不了解的float(滥用float的怪异现象) (转)
  8. linux安装和配置 mysql、redis 过程中遇到的问题记录(转)
  9. Python初探
  10. 找出共同好友 - 数据挖掘 - Scala版
  11. 学习 JavaScript(二)在 HTML 中使用 JS
  12. MySQL-mysql 8.0.11安装教程
  13. git 入门教程之 git 私服搭建教程
  14. Tuple Class
  15. numpy学习笔记.
  16. git入门(廖雪峰老师)
  17. [转帖]ASP.NET Core的Kestrel服务器
  18. 在nodejs中的集成虹软人脸识别
  19. STO单没有取进FP,IN_SAELS_ORDER表无,但IN_PO_STO有
  20. 使用FiddlerCore来截取替换Http请求中的网页内容

热门文章

  1. charles使用教程
  2. JPA单向和双向关系
  3. python_模块 hashlib ,configparser, logging
  4. 复习下KMP&amp;e-KMP
  5. Java中HashMap与ConcurrentHashMap的区别
  6. Android中使用VideoView 播放视频
  7. Spring项目下js文件无法引用
  8. Linux设置chrome缓存至内存,及开关机同步
  9. 取消SVN感叹号即去除版本库
  10. IntelliJ IDEA 添加本地xsd文件