Submission #3188592
Source Code Expand
#include <cstdio> #define N 1 << 16 | 3 const int mod = 1000000007; int n, m, s[20]; long long fac[N], inv[N]; long long f[17][N], ans, U; void update(long long &x, long long y) {if ((x += y) >= mod) x -= mod;} long long C(long long a, long long b) { if (a < b) return 0; return fac[a] * inv[b] % mod * inv[a - b] % mod; } int main () { scanf("%d%d", &n, &m); U = 1 << n; for (int i = 1; i <= m; i++) scanf("%d", s + m - i); fac[0] = fac[1] = inv[0] = inv[1] = 1; for (int i = 2; i < U; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = inv[mod % i] * (mod - mod / i) % mod; } for (int i = 2; i < U; i++) inv[i] = inv[i - 1] * inv[i] % mod; f[0][0] = 1; for (int i = 0; i < m; i++) { for (int j = 0; j < U; j++) { update(f[i + 1][j], f[i][j]); for (int k = 0; k < n; k++) { if (!(j & (1 << k))) update(f[i + 1][j | 1 << k], f[i][j] * fac[1 << k] % mod * C(U - j - s[i], (1 << k) - 1) % mod); } } } for (int i = 0; i < U; i++) { long long tmp = f[m][i] * fac[U - i - 1] % mod; update(ans, __builtin_parity(i) ? (mod - tmp) : tmp); } printf("%lld\n", ans * U % mod); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Dark Horse |
User | Memory_of_winter |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 1149 Byte |
Status | AC |
Exec Time | 146 ms |
Memory | 9344 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:13:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &n, &m); U = 1 << n; ^ ./Main.cpp:14:53: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for (int i = 1; i <= m; i++) scanf("%d", s + m - i); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1100 / 1100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, sample-05.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, sample-05.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 12 ms | 6656 KB |
02.txt | AC | 109 ms | 8832 KB |
03.txt | AC | 112 ms | 8832 KB |
04.txt | AC | 111 ms | 9344 KB |
05.txt | AC | 70 ms | 6784 KB |
06.txt | AC | 90 ms | 8832 KB |
07.txt | AC | 103 ms | 8832 KB |
08.txt | AC | 121 ms | 9344 KB |
09.txt | AC | 131 ms | 9344 KB |
10.txt | AC | 119 ms | 9344 KB |
11.txt | AC | 2 ms | 1152 KB |
12.txt | AC | 9 ms | 1664 KB |
13.txt | AC | 20 ms | 4736 KB |
14.txt | AC | 28 ms | 4736 KB |
15.txt | AC | 1 ms | 128 KB |
16.txt | AC | 1 ms | 2176 KB |
17.txt | AC | 1 ms | 2176 KB |
18.txt | AC | 1 ms | 4224 KB |
19.txt | AC | 1 ms | 2176 KB |
20.txt | AC | 1 ms | 6272 KB |
21.txt | AC | 137 ms | 9344 KB |
22.txt | AC | 126 ms | 9344 KB |
23.txt | AC | 103 ms | 9344 KB |
24.txt | AC | 76 ms | 9344 KB |
25.txt | AC | 80 ms | 6784 KB |
26.txt | AC | 41 ms | 4736 KB |
27.txt | AC | 2 ms | 4352 KB |
28.txt | AC | 1 ms | 128 KB |
29.txt | AC | 1 ms | 4224 KB |
30.txt | AC | 1 ms | 2176 KB |
31.txt | AC | 2 ms | 6272 KB |
32.txt | AC | 146 ms | 9344 KB |
33.txt | AC | 1 ms | 128 KB |
34.txt | AC | 1 ms | 2176 KB |
35.txt | AC | 1 ms | 4224 KB |
36.txt | AC | 1 ms | 6272 KB |
sample-01.txt | AC | 1 ms | 128 KB |
sample-02.txt | AC | 1 ms | 128 KB |
sample-03.txt | AC | 1 ms | 128 KB |
sample-04.txt | AC | 1 ms | 128 KB |
sample-05.txt | AC | 141 ms | 9344 KB |