I-nice to Meet

Source: Internet
Author: User

Portal

and 10-17 B is similar to the third question , should be considered as a simplified version, given a fixed point.

F[s] means that only the edges in the S collection are considered, and the fixed point in S (1 or 2) can reach the total number of scenarios for the entire set.

Preprocessing C[s] represents the total number of edges in the S collection, and the transfer uses all schemes to subtract a part of the s set that cannot be reached, that is, to enumerate a subset as reachable, the edge direction between the complement and the subset of the subset is determined, and the edges of the complement are arbitrarily selected, and none of the sides of the graph are selected or not

Unlike an s1,2 diagram, where the set of 1 points that can be reached is the set of points that can be reached for S2, (the edges in the s1,s2 complement are arbitrarily directed, the edge direction between the complement and the S1,S2 is determined only), and any point in the S1 cannot be connected to the point in the S2, Since a point x is not in S2 indicating that the edge of the point in the S2 set is pointing to S2, then x S1 and S2 are connected in S1.

At first it was WA three points, because I fixed a point when the enumeration subset can be 0 but I jumped out ...

 1 //Achen
 2 #include<bits/stdc++.h>
 3 #define For(i,a,b) for(int i=(a);i<=(b);i++)
 4 #define Rep(i,a,b) for(int i=(a);i>=(b);i--)
 5 #define Formylove return 0
 6 const int N=32777,p=1e9+7;
 7 typedef long long LL;
 8 typedef double db;
 9 using namespace std;
10 int n,m,a[123],b[123],mp[20][20];
11 LL pr[123],c[N],f[N],to[N];
12 LL ans;
13 
14 template<typename T> void read(T &x) {
15     char ch=getchar(); x=0; T f=1;
16     while(ch!=‘-‘&&(ch<‘0‘||ch>‘9‘)) ch=getchar();
17     if(ch==‘-‘) f=-1,ch=getchar();
18     for(;ch>=‘0‘&&ch<=‘9‘;ch=getchar()) x=x*10+ch-‘0‘; x*=f;
19 }
20 
21 //#define ANS
22 int main() {
23 #ifdef ANS
24     freopen("1.in","r",stdin);
25     freopen("1.out","w",stdout);
26 #endif
27     read(n); read(m);
28     pr[0]=1;
29     For(i,1,120) pr[i]=2LL*pr[i-1]%p;
30     For(i,1,m) {
31         read(a[i]); read(b[i]); 
32         mp[a[i]][b[i]]++;
33         mp[b[i]][a[i]]++;
34         c[pr[a[i]-1]+pr[b[i]-1]]++;
35     }
36     For(i,1,n) {
37         For(j,1,n) if(mp[i][j]) to[pr[i-1]]|=pr[j-1];
38     }
39     int up=pr[n]-1;
40     For(i,0,n-1) For(s,1,up) {
41         if(!(s&pr[i])) {
42             c[s|pr[i]]+=c[s];
43             to[s|pr[i]]|=to[s];
44         }
45     }
46     //For(i,1,up) printf("%d : %d\n",i,to[i]);
47     f[1]=f[2]=1;
48     For(s,3,up) {
49         LL t=0;
50         for(int ss=((s-1)&s);ss;ss=((ss-1)&s)) {
51             if((!(s&2)&&(s&1)&&!(ss&2)&&(ss&1))||(!(s&1)&&(s&2)&&!(ss&1)&&(ss&2))) 
52                 t=(t+f[ss]*pr[c[s^ss]]%p)%p;
53         }
54         if((!(s&2)&&(s&1))||(!(s&1)&&(s&2))) f[s]=(pr[c[s]]-t+p)%p;
55     }
56     For(s,1,up) if((s&1)&&!(s&2)) {
57         int S=(up^s)-2;
58         for(int ss=S;;ss=((ss-1)&S)) {
59             if((s&to[up^s^ss])!=0||((up^s^ss)&to[s])!=0) {
60                 if(!ss) break; else continue;
61             }
62             ans=(ans+f[s]*f[up^s^ss]%p*pr[c[ss]]%p)%p;
63             if(!ss) break;
64         }
65     }
66     printf("%lld\n",(pr[m]-ans+p)%p);
67     Formylove;
68 }
View Code

I-nice to Meet you

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.