I - Nice to Meet You
和10-17 B 君的第三题 类似,应该算是简化版,给出了固定的点。
f[s]表示只考虑连端都在s集合中的边,s中的固定点(1或者2)能到达整个集合的方案数。
预处理c[s]表示s集合中的总边数,转移就用所有方案减去s集合中有一部分不能到达的方案,也就是枚举一个子集作为能到达的,这个子集的补集和子集之间的边方向确定了,补集内的边随便选,也就和无向图每条边选或者不选等价了。
和无向图不同的是,1能到达的点的集合为s1,2能到达的点的集合为s2的时候,(s1,s2的补集内的边随便定向,补集和s1,s2之间的边方向唯一确定),s1中的任意点不能于s2中的点有连边,因为一个点x不在s2中表明它到s2集合内的点的边都是指向s2的,那么x若在s1中,s1和s2就联通了。
一开始一直wa三个点,因为我固定一个点的时候枚举子集可以为0但是我跳出了。。。
//Achen
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
#define Formylove return 0
const int N=,p=1e9+;
typedef long long LL;
typedef double db;
using namespace std;
int n,m,a[],b[],mp[][];
LL pr[],c[N],f[N],to[N];
LL ans; template<typename T> void read(T &x) {
char ch=getchar(); x=; T f=;
while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
if(ch=='-') f=-,ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
} //#define ANS
int main() {
#ifdef ANS
freopen("1.in","r",stdin);
freopen("1.out","w",stdout);
#endif
read(n); read(m);
pr[]=;
For(i,,) pr[i]=2LL*pr[i-]%p;
For(i,,m) {
read(a[i]); read(b[i]);
mp[a[i]][b[i]]++;
mp[b[i]][a[i]]++;
c[pr[a[i]-]+pr[b[i]-]]++;
}
For(i,,n) {
For(j,,n) if(mp[i][j]) to[pr[i-]]|=pr[j-];
}
int up=pr[n]-;
For(i,,n-) For(s,,up) {
if(!(s&pr[i])) {
c[s|pr[i]]+=c[s];
to[s|pr[i]]|=to[s];
}
}
//For(i,1,up) printf("%d : %d\n",i,to[i]);
f[]=f[]=;
For(s,,up) {
LL t=;
for(int ss=((s-)&s);ss;ss=((ss-)&s)) {
if((!(s&)&&(s&)&&!(ss&)&&(ss&))||(!(s&)&&(s&)&&!(ss&)&&(ss&)))
t=(t+f[ss]*pr[c[s^ss]]%p)%p;
}
if((!(s&)&&(s&))||(!(s&)&&(s&))) f[s]=(pr[c[s]]-t+p)%p;
}
For(s,,up) if((s&)&&!(s&)) {
int S=(up^s)-;
for(int ss=S;;ss=((ss-)&S)) {
if((s&to[up^s^ss])!=||((up^s^ss)&to[s])!=) {
if(!ss) break; else continue;
}
ans=(ans+f[s]*f[up^s^ss]%p*pr[c[ss]]%p)%p;
if(!ss) break;
}
}
printf("%lld\n",(pr[m]-ans+p)%p);
Formylove;
}
I - Nice to Meet You的更多相关文章
- tomcat 7 WARNING: A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []
tomcat 7 WARNING: A context path must either be an empty string or start with a '/' and do not end w ...
- bzoj1787 [Ahoi2008]Meet 紧急集合
1787: [Ahoi2008]Meet 紧急集合 Time Limit: 20 Sec Memory Limit: 162 MB Submit: 2272 Solved: 1029 [Submi ...
- 【BZOJ-1787&1832】Meet紧急集合&聚会 倍增LCA
1787: [Ahoi2008]Meet 紧急集合 Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 2259 Solved: 1023[Submit] ...
- How to disable Passwords must meet complexity requirements[windows 7]
The Password complexity is a Local Policy setting named "Passwords must meet complexity require ...
- Codeforces Round #325 (Div. 2) F. Lizard Era: Beginning meet in the mid
F. Lizard Era: Beginning Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
- bzoj 1787 [Ahoi2008]Meet 紧急集合(1832 [AHOI2008]聚会)
1787: [Ahoi2008]Meet 紧急集合 Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 1841 Solved: 857[Submit][ ...
- hadoop权威指南 chapter1 Meet Hadoop
Meet Hadoop 1.1 Data!(数据) Most of the data is locked up in the largest web properties (like search e ...
- BZOJ 1787: [Ahoi2008]Meet 紧急集合( 树链剖分 )
这道题用 LCA 就可以水过去 , 但是我太弱了 QAQ 倍增写LCA总是写残...于是就写了树链剖分... 其实也不难写 , 线段树也不用用到 , 自己YY一下然后搞一搞就过了...速度还挺快的好像 ...
- Meet Apache Wicket
第一次接触Wicket,如此多的内容是文字,的原贴,希望大家指正 Meet Apache Wicket By JonathanLocke, original author of Wicket 乔纳森· ...
- 1787: [Ahoi2008]Meet 紧急集合
1787: [Ahoi2008]Meet 紧急集合 Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 1482 Solved: 652[Submit][ ...
随机推荐
- QT blockingmaster例子学习
dialog.h: #ifndef DIALOG_H #define DIALOG_H #include <QDialog> #include "masterthread.h&q ...
- stat函数学习
stat函数组 前面介绍的通过ls命令查看到的文件信息,都可以使用stat函数组提取出来• stat函数组– 使用命令man stat查看相关文档• 函数int stat(const char *pa ...
- Linux CentOS-7.4-x86_64(原版) 百度网盘下载
因为CentOS-7-x86_64-DVD-1804.iso 镜像文件4.16G,超出了上传百度网盘的单个文件大小限制(4G), 所以这里先现将ISO镜像文件压缩成RAR包,然后上传网盘. 使用的话, ...
- location优先级
location优先级 location优先级 location /img # 直接匹配 location /img { index index.html } location = /img # 精确 ...
- ip协议,IP,子网掩码,ping命令是什么
ip协议: 定网络地址的协议叫ip协议,它定义的地址称之为ip地址,广泛采用的v4版本即ipv4,它规定网络地址由32位2进制表示 IP地址:是给每个连接在Internet上的主机分配的一个32bit ...
- 2、jQuery操作Dom(过滤器与选择器)
1.属性选择器 <script language="JavaScript"> /** * <input type="button" value ...
- WEBI更换数据源
有些时候,我们需要更换数据源.例如切了系统.重新导入数据源,这样我的webi重做的工作量太大.一些变量之类的.替换数据源就很好的解决.不过它应当是对大致80%甚至100%相似的数据源.具体业务具体分析 ...
- Codeforces 578B "Or" Game (前缀和 + 贪心)
Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] 题目链接:B. "Or" Game You are given \(n\) ...
- jmeter 不同线程组之间传递变量2
方法1 通过变量传递参数: 第一个脚本: HTTP Request_新建出差申请单_登录,关联出参数token.companyId.userId.userName 1.添加后置处理器:BeanShe ...
- Javascript高级程序设计--读书笔记之面向对象(一)
哈哈哈万物皆对象,终于到了js的面向对象篇. 一.属性类型 (1)数据属性 数据属性包含一个数据值的位置,在这个位置可以写入和读取数值,数据属性有四个描述器行为的特性 [[Configurable]] ...