# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
666467 | 2022-11-28T16:48:04 Z | finn__ | Amusement Park (CEOI19_amusementpark) | C++17 | 227 ms | 460 KB |
#include <bits/stdc++.h> using namespace std; #define MOD 998244353 int main() { size_t n, m; cin >> n >> m; vector<vector<bool>> g(n, vector<bool>(n, 0)); for (size_t i = 0; i < m; i++) { unsigned u, v; cin >> u >> v; g[u - 1][v - 1] = 1; } vector<int64_t> dp(1 << n, 0); dp[0] = 1; for (unsigned i = 1; i < 1 << n; i++) { unsigned const p = __builtin_popcount(i); vector<unsigned> s; for (unsigned k = 0; k < n; k++) if (i & (1 << k)) s.push_back(k); for (unsigned j = 0; j < 1 << p; j++) { bool is_independent = 1; for (unsigned k = 0; k < p && is_independent; k++) if (j & (1 << k)) for (unsigned h = 0; h < p && is_independent; h++) if (j & (1 << h)) if (g[s[k]][s[h]] || g[s[h]][s[k]]) is_independent = 0; if (is_independent) { unsigned t = 0; for (unsigned k = 0; k < p; k++) if (j & (1 << k)) t ^= (1 << s[k]); assert(__builtin_popcount(t) == __builtin_popcount(j)); dp[i] = (dp[i] + ((__builtin_popcount(t) & 1) ? 1 : -1) * dp[i ^ t]) % MOD; } } } cout << (dp[(1 << n) - 1] * m * 499122177) % MOD << '\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 300 KB | Output is correct |
4 | Correct | 1 ms | 300 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 300 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 300 KB | Output is correct |
4 | Correct | 1 ms | 300 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 300 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 300 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 300 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 300 KB | Output is correct |
4 | Correct | 1 ms | 300 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 300 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 300 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 300 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 300 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 300 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 1 ms | 212 KB | Output is correct |
37 | Correct | 1 ms | 212 KB | Output is correct |
38 | Correct | 1 ms | 212 KB | Output is correct |
39 | Correct | 2 ms | 212 KB | Output is correct |
40 | Correct | 2 ms | 212 KB | Output is correct |
41 | Correct | 2 ms | 212 KB | Output is correct |
42 | Correct | 2 ms | 256 KB | Output is correct |
43 | Correct | 2 ms | 212 KB | Output is correct |
44 | Correct | 2 ms | 212 KB | Output is correct |
45 | Correct | 1 ms | 212 KB | Output is correct |
46 | Correct | 1 ms | 212 KB | Output is correct |
47 | Correct | 1 ms | 212 KB | Output is correct |
48 | Correct | 3 ms | 212 KB | Output is correct |
49 | Correct | 1 ms | 300 KB | Output is correct |
50 | Correct | 2 ms | 212 KB | Output is correct |
51 | Correct | 2 ms | 304 KB | Output is correct |
52 | Correct | 6 ms | 308 KB | Output is correct |
53 | Correct | 4 ms | 212 KB | Output is correct |
54 | Correct | 4 ms | 212 KB | Output is correct |
55 | Correct | 3 ms | 264 KB | Output is correct |
56 | Correct | 3 ms | 212 KB | Output is correct |
57 | Correct | 2 ms | 212 KB | Output is correct |
58 | Correct | 2 ms | 212 KB | Output is correct |
59 | Correct | 2 ms | 212 KB | Output is correct |
60 | Correct | 2 ms | 212 KB | Output is correct |
61 | Correct | 6 ms | 304 KB | Output is correct |
62 | Correct | 4 ms | 300 KB | Output is correct |
63 | Correct | 4 ms | 296 KB | Output is correct |
64 | Correct | 5 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 300 KB | Output is correct |
4 | Correct | 1 ms | 300 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 300 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 300 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 300 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 300 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 300 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 1 ms | 212 KB | Output is correct |
37 | Correct | 1 ms | 212 KB | Output is correct |
38 | Correct | 1 ms | 212 KB | Output is correct |
39 | Correct | 2 ms | 212 KB | Output is correct |
40 | Correct | 2 ms | 212 KB | Output is correct |
41 | Correct | 2 ms | 212 KB | Output is correct |
42 | Correct | 2 ms | 256 KB | Output is correct |
43 | Correct | 2 ms | 212 KB | Output is correct |
44 | Correct | 2 ms | 212 KB | Output is correct |
45 | Correct | 1 ms | 212 KB | Output is correct |
46 | Correct | 1 ms | 212 KB | Output is correct |
47 | Correct | 1 ms | 212 KB | Output is correct |
48 | Correct | 3 ms | 212 KB | Output is correct |
49 | Correct | 1 ms | 300 KB | Output is correct |
50 | Correct | 2 ms | 212 KB | Output is correct |
51 | Correct | 2 ms | 304 KB | Output is correct |
52 | Correct | 6 ms | 308 KB | Output is correct |
53 | Correct | 4 ms | 212 KB | Output is correct |
54 | Correct | 4 ms | 212 KB | Output is correct |
55 | Correct | 3 ms | 264 KB | Output is correct |
56 | Correct | 3 ms | 212 KB | Output is correct |
57 | Correct | 2 ms | 212 KB | Output is correct |
58 | Correct | 2 ms | 212 KB | Output is correct |
59 | Correct | 2 ms | 212 KB | Output is correct |
60 | Correct | 2 ms | 212 KB | Output is correct |
61 | Correct | 6 ms | 304 KB | Output is correct |
62 | Correct | 4 ms | 300 KB | Output is correct |
63 | Correct | 4 ms | 296 KB | Output is correct |
64 | Correct | 5 ms | 212 KB | Output is correct |
65 | Correct | 227 ms | 340 KB | Output is correct |
66 | Correct | 186 ms | 424 KB | Output is correct |
67 | Incorrect | 175 ms | 460 KB | Output isn't correct |
68 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 300 KB | Output is correct |
4 | Correct | 1 ms | 300 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 300 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 300 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 300 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 300 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 300 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 1 ms | 212 KB | Output is correct |
37 | Correct | 1 ms | 212 KB | Output is correct |
38 | Correct | 1 ms | 212 KB | Output is correct |
39 | Correct | 2 ms | 212 KB | Output is correct |
40 | Correct | 2 ms | 212 KB | Output is correct |
41 | Correct | 2 ms | 212 KB | Output is correct |
42 | Correct | 2 ms | 256 KB | Output is correct |
43 | Correct | 2 ms | 212 KB | Output is correct |
44 | Correct | 2 ms | 212 KB | Output is correct |
45 | Correct | 1 ms | 212 KB | Output is correct |
46 | Correct | 1 ms | 212 KB | Output is correct |
47 | Correct | 1 ms | 212 KB | Output is correct |
48 | Correct | 3 ms | 212 KB | Output is correct |
49 | Correct | 1 ms | 300 KB | Output is correct |
50 | Correct | 2 ms | 212 KB | Output is correct |
51 | Correct | 2 ms | 304 KB | Output is correct |
52 | Correct | 6 ms | 308 KB | Output is correct |
53 | Correct | 4 ms | 212 KB | Output is correct |
54 | Correct | 4 ms | 212 KB | Output is correct |
55 | Correct | 3 ms | 264 KB | Output is correct |
56 | Correct | 3 ms | 212 KB | Output is correct |
57 | Correct | 2 ms | 212 KB | Output is correct |
58 | Correct | 2 ms | 212 KB | Output is correct |
59 | Correct | 2 ms | 212 KB | Output is correct |
60 | Correct | 2 ms | 212 KB | Output is correct |
61 | Correct | 6 ms | 304 KB | Output is correct |
62 | Correct | 4 ms | 300 KB | Output is correct |
63 | Correct | 4 ms | 296 KB | Output is correct |
64 | Correct | 5 ms | 212 KB | Output is correct |
65 | Correct | 227 ms | 340 KB | Output is correct |
66 | Correct | 186 ms | 424 KB | Output is correct |
67 | Incorrect | 175 ms | 460 KB | Output isn't correct |
68 | Halted | 0 ms | 0 KB | - |