Source: Internet
Author: User

Tags: alt LSE | | Namespace no map beta target targe Blank

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 //Achen2#include <bits/stdc++.h>3 #definefor (I,A,B) for (int i= (a); i<= (b); i++)4 #defineREP (I,A,B) for (int i= (a); i>= (b); i--)5 #defineFormylove return 06 Const intn=32777, p=1e9+7;7typedefLong LongLL;8typedefDoubledb;9 using namespacestd;Ten intn,m,a[123],b[123],mp[ -][ -]; OneLL pr[123],c[n],f[n],to[n]; A LL ans; - -Template<typename t>voidRead (T &x) { the CharCh=getchar (); x=0; T f=1; - while(ch!='-'&& (ch<'0'|| Ch>'9')) ch=GetChar (); - if(ch=='-') f=-1, ch=GetChar (); - for(; ch>='0'&&ch<='9'; Ch=getchar ()) x=x*Ten+ch-'0'; x*=F; + } - + //#define ANS A intMain () { at #ifdef ANS -Freopen ("1.in","R", stdin); -Freopen ("1.out","W", stdout); - #endif - read (n); read (m); -pr[0]=1; infor (I,1, -) pr[i]=2ll*pr[i-1]%p; -for (I,1, M) { to read (a[i]); Read (B[i]); +mp[a[i]][b[i]]++; -mp[b[i]][a[i]]++; thec[pr[a[i]-1]+pr[b[i]-1]]++; * } $for (I,1, N) {Panax NotoginsengFor (J,1, N)if(Mp[i][j]) to[pr[i-1]]|=pr[j-1]; - } the intup=pr[n]-1; +for (I,0, N-1) for (S,1, up) { A if(! (s&Pr[i])) { thec[s|pr[i]]+=C[s]; +to[s|pr[i]]|=To[s]; - } $ } $ //for (i,1,up) printf ("%d:%d\n", I,to[i]); -f[1]=f[2]=1; -for (S,3, up) { theLL t=0; - for(intSs= (S-1) (&s); ss;ss= (ss-1) &s)) {Wuyi if((! (s&2) && (s&1) &&! (ss&2) && (ss&1))|| (! (s&1) && (s&2) &&! (ss&1) && (ss&2))) thet= (t+f[ss]*pr[c[s^ss]]%p)%p; - } Wu if((! (s&2) && (s&1))|| (! (s&1) && (s&2))) f[s]= (pr[c[s]]-t+p)%p; - } Aboutfor (S,1, up)if((s&1) &&! (s&2)) { $ intS= (Up^s)-2; - for(intSs=s;; Ss= ((ss-1) &S)) { - if((S&TO[UP^S^SS])! =0|| ((UP^S^SS) &to[s])! =0) { - if(!SS) Break;Else Continue; A } +ans= (ans+f[s]*f[up^s^ss]%p*pr[c[ss]]%p)%p; the if(!SS) Break; - } $ } theprintf"%lld\n", (pr[m]-ans+p)%p); the Formylove; the}View Code

I-nice to Meet you