Preface
It feels like a simple DP.
It must be shape pressure.
Then you just need to think about dividing by mex.
meaning of the title
A directed acyclic graph, finding out how many subsets of edge sets constitute a graph, so that sg1 xor SG2 > 0
DP
The positive and the negative are considered to make the values of 1 and 2sg equal.
Let dps denote that only the answer to the set of s points is considered (1 and 2 may not be included).
We divide s into A and B, where B is the smallest point set of mex. Then each point in A should be connected to at least one side of B, and the middle point of B can be connected to A at will. The remaining scheme is dpA.
Of course, we do not allow 1 and 2 to be separated into A and B. They must be in A or B at the same time.
Then GI can be preprocessed, s means the number of schemes o n at least one side of i-connected s, and fi,s means the number of edges o n i-connected s. The scheme calculation can achieve o(n).
The complexity of enumerating sets and subsets is 3n.
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int mo=1000000007;
bool bz[15+5][15+5];
int two[300],id[1<<17];
int f[15+5][1<<17],g[15+5][1<<17],dp[1<<17];
int i,j,k,l,r,s,t,n,m,ans;
int lowbit(int x){
return x&-x;
}
int main(){
scanf("%d%d",&n,&m);
fo(i,1,n) id[1<<(i-1)]=i;
two[0]=1;
fo(i,1,m) two[i]=(ll)two[i-1]*2%mo;
fo(i,1,m){
scanf("%d%d",&j,&k);
bz[j][k]=1;
}
fo(i,1,n)
fo(s,1,(1<<n)-1)
f[i][s]=f[i][s-lowbit(s)]+bz[i][id[lowbit(s)]];
fo(i,1,n)
fo(s,1,(1<<n)-1){
k=id[lowbit(s)];
if (!bz[i][k]) g[i][s]=g[i][s-lowbit(s)];
else g[i][s]=((ll)g[i][s-lowbit(s)]*2%mo+1)%mo;
}
fo(s,1,(1<<n)-1){
//if (!((s&1)&&(s&2))) continue;
dp[s]=1;
t=(s-1)&s;
while (t){
if (((s^t)&1)&&(t&2)){
t=(t-1)&s;
continue;
}
if (((s^t)&2)&&(t&1)){
t=(t-1)&s;
continue;
}
r=1;
fo(i,1,n)
if ((t&(1<<(i-1)))) r=(ll)r*g[i][s^t]%mo;
l=0;
fo(i,1,n)
if (((s^t)&(1<<(i-1)))) l+=f[i][t];
r=(ll)r*two[l]%mo;
(dp[s]+=(ll)dp[t]*r%mo)%=mo;
t=(t-1)&s;
}
}
ans=(two[m]-dp[(1<<n)-1])%mo;
(ans+=mo)%=mo;
printf("%d\n",ans);
}