Submission #5943702


Source Code Expand

// start fold
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
using namespace std;
#define ri register int
#define il inline
#define LL long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define enter putchar('\n')
#define size(x) ((int)x.size())
#define mem0(x) memset(x,0,sizeof(x))
template<class T>il void in(T &x)
{
	x=0; short f=1; char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') x=x*10+(c^'0'),c=getchar();
	x*=f;
}
template <typename T,typename ...Args>il void in(T &x, Args &...args)
{
	in(x); in(args...);
}
template<class T>il void out(T x,const char c='\n')
{
	static short st[30];
	short m=0;
	if(x<0) putchar('-'),x=-x;
	do st[++m]=x%10,x/=10; while(x);
	while(m) putchar(st[m--]|'0');
	putchar(c);
}
template <typename T,typename ...Args>il void out(const T &x,const Args &...args)
{
	out(x,' '); out(args...);
}
template<class T>il void print(T a[],int n)
{
	if(n<=0) return;
	for(ri i=0; i<n; ++i) out(a[i],' ');
	enter;
}
namespace i207M
{
// end fold
#define N 16
#define M N*N
const int md=1e9+7;
int n,m;
int v[M],nx[M],head[N],cnte=1;
il void adde(const int uu,const int vv)
{
	v[++cnte]=vv,nx[cnte]=head[uu],head[uu]=cnte;
}
int ined[1<<N];
int f[2][1<<N];
int pw2[M];
int bit,ys[1<<N];
signed main()
{
#ifdef M207
	freopen("in.in","r",stdin);
	// freopen("out.out","w",stdout);
#endif
	in(n,m); pw2[0]=1; bit=(1<<n)-1;
	for(ri i=0; i<n; ++i) ys[1<<i]=i;
	for(ri i=1,a,b; i<=m; ++i)
	{
		in(a,b); --a,--b;
		adde(a,b), adde(b,a);
		pw2[i]=(pw2[i-1]<<1)%md;
	}
	for(ri s=1; s<=bit; ++s)
	{
		int x=s&-s;
		ined[s]=ined[s^x],x=ys[x];
		for(ri i=head[x]; i; i=nx[i])
			if((s>>v[i])&1) ++ined[s];
	}
	for(ri c=0; c<=1; ++c)
		for(ri s=1; s<=bit; ++s)
			if((s>>c)&1)
			{
				int val=pw2[ined[s]];
				for(ri t=s&(s-1); t; t=s&(t-1))
					if((t>>c)&1)
					{
						val=(val-(LL)f[c][t]*pw2[ined[s^t]]%md+md)%md;
					}
				f[c][s]=val;
			}
	int ans=0;
	for(ri s=1; s<=bit; ++s)
		if(s&1)
		{
			int bu=bit^s;
			for(ri t=bu; t; t=bu&(t-1))
				if((t&2)&&ined[s]+ined[t]==ined[s|t])
					ans=(ans+(LL)f[0][s]*f[1][t]%md*pw2[ined[(s|t)^bit]])%md;
		}
	ans=(pw2[m]-ans+md)%md;
	out(ans);
	return 0;
}
// start fold
}
signed main()
{
	i207M::main();
	return 0;
}
// end fold

Submission Info

Submission Time
Task I - Nice to Meet You
User vjudge2
Language C++14 (GCC 5.4.1)
Score 100
Code Size 2477 Byte
Status AC
Exec Time 63 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 63
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49, b50, b51, b52, b53, b54, b55, b56, b57, b58, b59, b60, b61, b62, b63
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 60 ms 640 KB
b06 AC 63 ms 640 KB
b07 AC 61 ms 640 KB
b08 AC 61 ms 640 KB
b09 AC 60 ms 640 KB
b10 AC 60 ms 640 KB
b11 AC 60 ms 640 KB
b12 AC 60 ms 640 KB
b13 AC 60 ms 640 KB
b14 AC 61 ms 640 KB
b15 AC 61 ms 640 KB
b16 AC 60 ms 640 KB
b17 AC 59 ms 640 KB
b18 AC 61 ms 640 KB
b19 AC 60 ms 640 KB
b20 AC 60 ms 640 KB
b21 AC 60 ms 640 KB
b22 AC 60 ms 640 KB
b23 AC 61 ms 640 KB
b24 AC 61 ms 640 KB
b25 AC 61 ms 640 KB
b26 AC 61 ms 640 KB
b27 AC 21 ms 512 KB
b28 AC 1 ms 256 KB
b29 AC 1 ms 256 KB
b30 AC 1 ms 256 KB
b31 AC 3 ms 256 KB
b32 AC 59 ms 640 KB
b33 AC 60 ms 640 KB
b34 AC 60 ms 640 KB
b35 AC 60 ms 640 KB
b36 AC 60 ms 640 KB
b37 AC 61 ms 640 KB
b38 AC 60 ms 640 KB
b39 AC 60 ms 640 KB
b40 AC 60 ms 640 KB
b41 AC 60 ms 640 KB
b42 AC 60 ms 640 KB
b43 AC 60 ms 640 KB
b44 AC 61 ms 640 KB
b45 AC 61 ms 640 KB
b46 AC 61 ms 640 KB
b47 AC 60 ms 640 KB
b48 AC 60 ms 640 KB
b49 AC 61 ms 640 KB
b50 AC 60 ms 640 KB
b51 AC 60 ms 640 KB
b52 AC 61 ms 640 KB
b53 AC 60 ms 640 KB
b54 AC 60 ms 640 KB
b55 AC 60 ms 640 KB
b56 AC 61 ms 640 KB
b57 AC 60 ms 640 KB
b58 AC 60 ms 640 KB
b59 AC 60 ms 640 KB
b60 AC 60 ms 640 KB
b61 AC 60 ms 640 KB
b62 AC 61 ms 640 KB
b63 AC 60 ms 640 KB