Submission #1886980
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef vector<int> vi; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<(n);i++) #define ALL(c) (c).begin(),(c).end() const ll MOD = 1000000007; int N, M; ll p2[310]; bool e[16][16]; ll dp[1 << 15]; int main() { p2[0] = 1; for (int i = 1; i < 310; ++i) { p2[i] = p2[i-1] * 2 % MOD; } cin >> N >> M; rep(i, M) { int x, y; cin >> x >> y; --x; --y; e[x][y] = 1; } dp[0] = 1; for (int i = 1; i < (1 << N); ++i) { for (int j = i; j >= 0; --j) { j &= i; int nx = j ^ i; if (dp[j] == 0 || ((nx & 1) && (nx & 2))) { continue; } int rem = ((1 << N) - 1) ^ i; ll way = 1; rep(k, N) { if ((rem >> k) & 1) { int cnt = 0; rep(t, N) if ((nx >> t) & 1) { if (e[k][t]) { ++cnt; } } way = way * (p2[cnt] - 1) % MOD; } else if ((j >> k) & 1) { int cnt = 0; rep(t, N) if ((nx >> t) & 1) { if (e[k][t]) { ++cnt; } } way = way * p2[cnt] % MOD; } } dp[i] = (dp[i] + dp[j] * way) % MOD; } } cout << dp[(1 << N) - 1] << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Games on DAG |
User | satashun |
Language | C++14 (GCC 5.4.1) |
Score | 1600 |
Code Size | 1373 Byte |
Status | AC |
Exec Time | 1702 ms |
Memory | 640 KB |
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 | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
0_03.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 21 ms | 512 KB |
1_02.txt | AC | 21 ms | 512 KB |
1_03.txt | AC | 1702 ms | 640 KB |
1_04.txt | AC | 1635 ms | 512 KB |
1_05.txt | AC | 1697 ms | 512 KB |
1_06.txt | AC | 589 ms | 512 KB |
1_07.txt | AC | 1622 ms | 512 KB |
1_08.txt | AC | 1697 ms | 512 KB |
1_09.txt | AC | 1643 ms | 512 KB |
1_10.txt | AC | 1679 ms | 512 KB |
1_11.txt | AC | 1205 ms | 512 KB |
1_12.txt | AC | 1691 ms | 512 KB |
1_13.txt | AC | 1690 ms | 512 KB |
1_14.txt | AC | 1697 ms | 512 KB |
1_15.txt | AC | 1359 ms | 512 KB |
1_16.txt | AC | 1206 ms | 512 KB |
1_17.txt | AC | 1697 ms | 512 KB |
1_18.txt | AC | 582 ms | 512 KB |
1_19.txt | AC | 1697 ms | 512 KB |
1_20.txt | AC | 44 ms | 512 KB |
1_21.txt | AC | 5 ms | 256 KB |
1_22.txt | AC | 523 ms | 512 KB |
1_23.txt | AC | 531 ms | 512 KB |
1_24.txt | AC | 38 ms | 384 KB |
1_25.txt | AC | 2 ms | 256 KB |
1_26.txt | AC | 1110 ms | 512 KB |
1_27.txt | AC | 18 ms | 256 KB |
1_28.txt | AC | 21 ms | 512 KB |
1_29.txt | AC | 151 ms | 256 KB |
1_30.txt | AC | 2 ms | 256 KB |
1_31.txt | AC | 1592 ms | 512 KB |
1_32.txt | AC | 149 ms | 256 KB |
1_33.txt | AC | 12 ms | 256 KB |
1_34.txt | AC | 171 ms | 384 KB |
1_35.txt | AC | 147 ms | 256 KB |