Submission #1792486
Source Code Expand
# include <bits/stdc++.h>
using namespace std;
# define REP(i, a, b) for(int i = a; i <= b; ++ i)
# define REPG(i, h, x) for(int i = h[x]; ~i; i = edge[i].next)
# define CLR(i, a) memset(i, a, sizeof(i))
# define REPD(i, a, b) for(int i = a; i >= b; -- i)
const int N = 15 + 5, N_ = 15, M = 15 * 14 / 2 + 5, MOD = 1e9 + 7;
typedef long long ll;
//f[i][S]
// g[i][S]
bool e[N][N];
int n, m, S;
int g[N][(1 << 17)], f[N][(1 << 17)];
int dp[(1 << 17)], id[N], pw[300];
inline void inc(int &a, int b) { a = (a + b) % MOD; }
void pre() {
REP(i, 1, n) {
REP(j, 0, S) {
f[i][j] = f[i][j - (j&-j)] + e[i][id[j&-j]];
}
}
REP(i, 1, n) {
REP(j, 0, S) {
int p = j & -j;
if(e[i][id[p]]) inc(g[i][j], (g[i][j - p] * 2 + 1) % MOD);
else g[i][j] = g[i][j - p] % MOD;
}
}
}
int main() {
scanf("%d%d", &n, &m);
S = (1 << n) - 1;
pw[0] = 1;
REP(i, 1, n) id[(1 << i - 1)] = i;
REP(i, 1, m) pw[i] = 1ll * pw[i - 1] * 2 % MOD; //1ll
REP(i, 1, m) {
int x, y; scanf("%d%d", &x, &y);
e[x][y] = 1;
}
pre();
dp[0] = 1;
REP(s, 1, S) {
for(int t = (s - 1) & s; ; -- t, t &= s) { // origin
// if(((t & 1) ^ (t & 2)) == 0) {
if (((((s^t)&1)&&(t&2)) == 0) && ((((s^t)&2)&&(t&1)) == 0)) {
int tmp = 1, tmp2 = 0;
for(int j = t; j; j -= j & -j) tmp = 1ll * tmp * g[id[j & -j]][t ^ s] % MOD;
for(int j = t ^ s; j; j -= j & -j) inc(tmp2, f[id[j & -j]][t]);
inc(dp[s], 1ll * (1ll * (1ll * pw[tmp2] % MOD) * tmp % MOD) * dp[t] % MOD);
}
if(!t) break;
}
}
printf("%d\n", (((pw[m] - dp[S]) % MOD) + MOD) % MOD);
return 0;
}
/*5 10
2 4
3 4
2 5
2 3
1 2
3 5
1 3
1 5
4 5
1 4
*/
Submission Info
Submission Time |
|
Task |
F - Games on DAG |
User |
shadyqwq |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1696 Byte |
Status |
RE |
Exec Time |
631 ms |
Memory |
19072 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:37:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
^
./Main.cpp:43:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int x, y; scanf("%d%d", &x, &y);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 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 |
2 ms |
2304 KB |
0_01.txt |
AC |
2 ms |
6400 KB |
0_02.txt |
AC |
2 ms |
6400 KB |
0_03.txt |
AC |
3 ms |
6400 KB |
1_00.txt |
AC |
2 ms |
2304 KB |
1_01.txt |
AC |
631 ms |
19072 KB |
1_02.txt |
AC |
629 ms |
19072 KB |
1_03.txt |
RE |
104 ms |
18944 KB |
1_04.txt |
RE |
106 ms |
18944 KB |
1_05.txt |
RE |
105 ms |
18944 KB |
1_06.txt |
RE |
107 ms |
18944 KB |
1_07.txt |
RE |
105 ms |
18944 KB |
1_08.txt |
RE |
104 ms |
18944 KB |
1_09.txt |
RE |
104 ms |
18944 KB |
1_10.txt |
RE |
105 ms |
18944 KB |
1_11.txt |
RE |
104 ms |
18944 KB |
1_12.txt |
RE |
108 ms |
18944 KB |
1_13.txt |
RE |
109 ms |
18944 KB |
1_14.txt |
RE |
107 ms |
18944 KB |
1_15.txt |
RE |
112 ms |
18944 KB |
1_16.txt |
RE |
108 ms |
18944 KB |
1_17.txt |
RE |
106 ms |
18944 KB |
1_18.txt |
RE |
104 ms |
18944 KB |
1_19.txt |
RE |
104 ms |
18944 KB |
1_20.txt |
RE |
106 ms |
18944 KB |
1_21.txt |
RE |
103 ms |
10496 KB |
1_22.txt |
RE |
104 ms |
18944 KB |
1_23.txt |
RE |
105 ms |
18944 KB |
1_24.txt |
RE |
116 ms |
14720 KB |
1_25.txt |
RE |
102 ms |
10496 KB |
1_26.txt |
RE |
108 ms |
18944 KB |
1_27.txt |
RE |
104 ms |
14592 KB |
1_28.txt |
WA |
631 ms |
19072 KB |
1_29.txt |
RE |
103 ms |
14720 KB |
1_30.txt |
AC |
23 ms |
14592 KB |
1_31.txt |
RE |
104 ms |
18944 KB |
1_32.txt |
RE |
103 ms |
14720 KB |
1_33.txt |
RE |
103 ms |
14592 KB |
1_34.txt |
RE |
106 ms |
14720 KB |
1_35.txt |
RE |
105 ms |
14720 KB |