Submission #2151944
Source Code Expand
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define fo(i,j,k) for(int i=j;i<=k;++i)
#define fd(i,j,k) for(int i=j;i>=k;--i)
#define ll long long
using namespace std;
const int N=16,M=300,mo=1e9+7;
ll f[1<<N];
int mp[N][1<<N];
int main()
{
int n,m;
scanf("%d %d",&n,&m);
fo(i,1,m){
int x,y;
scanf("%d %d",&x,&y);
mp[x][1<<y-1]=1;
}
fo(i,1,n)
fo(j,1,(1<<n)-1) mp[i][j]=mp[i][j-(j&-j)]+mp[i][(j&-j)];
f[0]=1;
fo(S,1,(1<<n)-1) if((S&1)==((S&2)>>1)){
f[S]=1;
for(int T=(S-1)&S;T;T=(T-1)&S) if((T&1)==((T&2)>>1)){
int x=S^T;
ll t=f[x];
if(!t) continue;
fo(i,1,n) if(x&(1<<i-1)) t=t*((1<<mp[i][T])-1)%mo;
else if(T&(1<<i-1)) t=t*(1<<mp[i][x])%mo;
f[S]=(f[S]+t)%mo;
}
}
ll ans=1;
fo(i,1,m) ans=ans*2%mo;
printf("%lld",(ans-f[(1<<n)-1]+mo)%mo);
}
Submission Info
Submission Time |
|
Task |
F - Games on DAG |
User |
sadstone |
Language |
C++14 (GCC 5.4.1) |
Score |
1600 |
Code Size |
847 Byte |
Status |
AC |
Exec Time |
381 ms |
Memory |
3456 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&n,&m);
^
./Main.cpp:18:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&x,&y);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
1600 / 1600 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All |
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt |
Case Name |
Status |
Exec Time |
Memory |
0_00.txt |
AC |
1 ms |
128 KB |
0_01.txt |
AC |
1 ms |
128 KB |
0_02.txt |
AC |
1 ms |
128 KB |
0_03.txt |
AC |
1 ms |
128 KB |
1_00.txt |
AC |
1 ms |
128 KB |
1_01.txt |
AC |
376 ms |
3456 KB |
1_02.txt |
AC |
376 ms |
3328 KB |
1_03.txt |
AC |
376 ms |
3456 KB |
1_04.txt |
AC |
376 ms |
3328 KB |
1_05.txt |
AC |
376 ms |
3456 KB |
1_06.txt |
AC |
376 ms |
3328 KB |
1_07.txt |
AC |
376 ms |
3328 KB |
1_08.txt |
AC |
375 ms |
3456 KB |
1_09.txt |
AC |
376 ms |
3456 KB |
1_10.txt |
AC |
376 ms |
3328 KB |
1_11.txt |
AC |
376 ms |
3456 KB |
1_12.txt |
AC |
377 ms |
3328 KB |
1_13.txt |
AC |
376 ms |
3456 KB |
1_14.txt |
AC |
376 ms |
3328 KB |
1_15.txt |
AC |
376 ms |
3328 KB |
1_16.txt |
AC |
375 ms |
3456 KB |
1_17.txt |
AC |
376 ms |
3456 KB |
1_18.txt |
AC |
381 ms |
3456 KB |
1_19.txt |
AC |
376 ms |
3328 KB |
1_20.txt |
AC |
376 ms |
3328 KB |
1_21.txt |
AC |
2 ms |
2304 KB |
1_22.txt |
AC |
376 ms |
3328 KB |
1_23.txt |
AC |
376 ms |
3328 KB |
1_24.txt |
AC |
122 ms |
2816 KB |
1_25.txt |
AC |
1 ms |
2304 KB |
1_26.txt |
AC |
376 ms |
3328 KB |
1_27.txt |
AC |
14 ms |
2432 KB |
1_28.txt |
AC |
375 ms |
3328 KB |
1_29.txt |
AC |
40 ms |
2560 KB |
1_30.txt |
AC |
14 ms |
2432 KB |
1_31.txt |
AC |
376 ms |
3328 KB |
1_32.txt |
AC |
40 ms |
2560 KB |
1_33.txt |
AC |
14 ms |
2432 KB |
1_34.txt |
AC |
122 ms |
2816 KB |
1_35.txt |
AC |
40 ms |
2560 KB |