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][ ...
随机推荐
- php错误提示
1.配置php.ini打开php.ini,把display_errors = Off 改成 display_errors = On然后找到 error_reporting 最好设置成error_rep ...
- js打印窗口内容并当窗口内容较长时自动分页
项目环境Angular: 方法1.window.print() HTML页面上的代码: <div id="tenementBillTable" class="dia ...
- python爬虫https://www.imdb.com/chart/top的电影
目标:爬取https://www.imdb.com/chart/top网页上面的电影top20 直接上main.py代码: #!/usr/bin/python35 # -*- coding:utf-8 ...
- 为什么NULL能多次free
void __cdecl _free_base (void * pBlock) { int retval = 0; if (pBlock == NULL) ...
- Java短路运算符和非短路运算符
在Java中短路运算符指的是"&&"(与) 和"||"(或) ,非短路运算符指的是"&" 和"|" ...
- PAT_A1131#Subway Map
Source: PAT A1131 Subway Map (30 分) Description: In the big cities, the subway systems always look s ...
- upc组队赛12 Cardboard Container【枚举】
Cardboard Container Problem Description fidget spinners are so 2017; this years' rage are fidget cub ...
- java 并发——CountDownLatch
java 并发--CountDownLatch 简介 public class CountDownLatch { private final Sync sync; private static fin ...
- Java DOM解析器 - 解析XML文档
使用DOM的步骤 以下是在使用DOM解析器解析文档使用的步骤. 导入XML相关的软件包. 创建DocumentBuilder 从文件或流创建一个文档 提取根元素 检查属性 检查子元素 导入XML相关的 ...
- SmartSql简介
0. Why 拥抱 跨平台 DotNet Core,是时候了. 高性能.高生产力,史上最轻量级的ORM.107kb 1. So SmartSql TargetFrameworks: .NETFrame ...