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][ ...
随机推荐
- 存储过程中的in out in out 三种类型的参数
in 是参数的默认模式,这种模式就是在程序运行的时候已经具有值,在程序体中值不会改变. out模式定义的参数只能在过程体内部赋值,表示该参数可以将某个值传递回调用他的过程 in out 表示高参数可以 ...
- hdu 6092 Rikka with Subset (集合计数,01背包)
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...
- BZOJ 3622: 已经没有什么好害怕的了(二项式反演)
传送门 解题思路 首先将\(a\),\(b\)排序,然后可以算出\(t(i)\),表示\(a(i)\)比多少个\(b(i)\)大,根据容斥套路,设\(f(k)\)表示恰好有\(k\)个\(a(i)\) ...
- MySQL安装/卸载
http://jishu8.cc/2017/02/06/55/ 检查端口是否冲突:netstat nao | findstr 3307 启动服务:services.msc
- mysql数据权限操作
1.创建新用户 通过root用户登录之后创建 >> grant all privileges on *.* to testuser@localhost identified by &quo ...
- cent OS 7 下安装 python 3.6
step1:安装依赖环境 # yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readli ...
- 简单使用Laravel-admin构建一个功能强大的后台管理
Laravel-admin可以快速构建一个功能强大的后台,方便快速开发. 以下内容记录简单使用Laravel-admin,以及遇到小错误的解决方法. Laravel-admin 依赖以下环境 需要提前 ...
- (3)C++复合类型
存储数据时必须跟踪的三个属性:信息储存在何处,存储的值,存储的类型 一.数组 #include <iostream> using namespace std; int main() { / ...
- spring+freemarker 乱码解决办法
这样应该可以了~ <!-- freemarker config --> <bean id="freemarkerConfig" class="org.s ...
- Java DOM解析器 - 解析XML文档
使用DOM的步骤 以下是在使用DOM解析器解析文档使用的步骤. 导入XML相关的软件包. 创建DocumentBuilder 从文件或流创建一个文档 提取根元素 检查属性 检查子元素 导入XML相关的 ...