博客
关于我
BZOJ 3812 主旋律
阅读量:283 次
发布时间:2019-03-01

本文共 1822 字,大约阅读时间需要 6 分钟。

题目链接

题解

考虑求非强连通子图的数量,假设为 g g g,那么答案就是 2 m − g 2^m-g 2mg。现在考虑求 g g g

假设 f s f_s fs表示用 s s s这些点能构成的强连通图的个数, g s g_s gs表示用 s s s这些点能构成的非强连通图的方案数,其中构成 i i i个强连通分量则对 g s g_s gs的贡献为 ( − 1 ) i (-1)^i (1)i。容易发现

g s = f s − ∑ t ⊂ s , u ∈ t g t f s − t g_s=f_s-\sum_{t\subset s,u\in t} g_tf_{s-t} gs=fsts,utgtfst
那么
f s = 2 e s − ∑ t ⊆ s , t ̸ = ∅ 2 e s − t + e s − t , t g s f_s=2^{e_s}-\sum_{t\subseteq s,t\not= \varnothing}2^{e_{s-t}+e_{s-t,t}}g_s fs=2ests,t̸=2est+est,tgs
容易发现, f s f_s fs此时需要的是不包含 f s f_s fs g s g_s gs,因此 g s g_s gs在求出 f s f_s fs之前是不能 + f s +f_s +fs的。

代码

#include 
int read(){ int x=0,f=1; char ch=getchar(); while((ch<'0')||(ch>'9')) { if(ch=='-') { f=-f; } ch=getchar(); } while((ch>='0')&&(ch<='9')) { x=x*10+ch-'0'; ch=getchar(); } return x*f;} const int maxn=15;const int maxm=1<
=mod) { pow[i]-=mod; } } f[0]=g[0]=1; for(int s=1; s<=full; ++s) { int sk=s^lowbit(s); for(int t=sk; t; t=sk&(t-1)) { g[s]-=1ll*f[s^t]*g[t]%mod; if(g[s]<0) { g[s]+=mod; } } for(int i=1; i<=n; ++i) { if((1<<(i-1))&s) { in[s]+=ecnt[s][i]; } } f[s]+=pow[in[s]]; for(int t=s; t; t=s&(t-1)) { int e=0; for(int i=1; i<=n; ++i) { if((1<<(i-1))&t) { e+=ecnt[s^t][i]; } } f[s]-=1ll*pow[e+in[s^t]]*g[t]%mod; if(f[s]<0) { f[s]+=mod; } } g[s]+=f[s]; if(g[s]>=mod) { g[s]-=mod; } } printf("%d\n",f[full]); return 0;}

转载地址:http://scwo.baihongyu.com/

你可能感兴趣的文章
nginx+tomcat+memcached
查看>>
nginx+tomcat单个域名及多个域名配置
查看>>
Nginx+Tomcat实现动静分离
查看>>
nginx+Tomcat性能监控
查看>>
nginx+uwsgi+django
查看>>
nginx+vsftp搭建图片服务器
查看>>
Nginx-http-flv-module流媒体服务器搭建+模拟推流+flv.js在前端html和Vue中播放HTTP-FLV视频流
查看>>
nginx-vts + prometheus 监控nginx
查看>>
Nginx/Apache反向代理
查看>>
Nginx: 413 – Request Entity Too Large Error and Solution
查看>>
nginx: [emerg] getpwnam(“www”) failed 错误处理方法
查看>>
nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:
查看>>
nginx: [error] open() “/usr/local/nginx/logs/nginx.pid“ failed (2: No such file or directory)
查看>>
nginx:Error ./configure: error: the HTTP rewrite module requires the PCRE library
查看>>
Nginx:objs/Makefile:432: recipe for target ‘objs/src/core/ngx_murmurhash.o‘解决方法
查看>>
nginxWebUI runCmd RCE漏洞复现
查看>>
nginx_rtmp
查看>>
Vue中向js中传递参数并在js中定义对象并转换参数
查看>>
Nginx、HAProxy、LVS
查看>>
nginx一些重要配置说明
查看>>