Submission #599791

# Submission time Handle Problem Language Result Execution time Memory
599791 2022-07-19T23:00:55 Z flappybird Amusement Park (CEOI19_amusementpark) C++17
100 / 100
1468 ms 3500 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 20
#define MAXS 18
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define smin(a, x) (a)=(min((a), (x)))
ll dp[303030];
int ban[MAX];
int mul[303030];
const int mod = 998244353;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int N, M;
	cin >> N >> M;
	int i, j, a, b;
	for (i = 1; i <= M; i++) {
		cin >> a >> b;
		ban[--a] |= 1 << --b;
		ban[b] |= 1 << a;
	}
	int K = 1 << N;
	dp[0] = 1;
	for (j = 0; j < K; j++) {
		int c = 0;
		for (int k = 0; k < N; k++) if ((j & (1 << k)) && (ban[k] & j)) c = 1;
		if (c) continue;
		mul[j] = -1;
		for (int k = 0; k < N; k++) if (j & (1 << k)) mul[j] *= -1;
	}
	for (i = 0; i < K; i++) { for (j = i; j; (--j) &= i) { dp[i] += dp[i ^ j] * (ll)mul[j], dp[i] %= mod; } }
	if (dp[K - 1] < 0ll) dp[K - 1] += mod;
	dp[K - 1] *= M;
	dp[K - 1] %= mod;
	if (dp[K - 1] % 2) dp[K - 1] += mod;
	dp[K - 1] /= 2;
	cout << dp[K - 1] << ln;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 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 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 1 ms 324 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 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 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 1 ms 324 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 18 ms 468 KB Output is correct
66 Correct 18 ms 504 KB Output is correct
67 Correct 19 ms 468 KB Output is correct
68 Correct 18 ms 432 KB Output is correct
69 Correct 18 ms 476 KB Output is correct
70 Correct 18 ms 468 KB Output is correct
71 Correct 18 ms 468 KB Output is correct
72 Correct 19 ms 444 KB Output is correct
73 Correct 19 ms 516 KB Output is correct
74 Correct 20 ms 488 KB Output is correct
75 Correct 18 ms 468 KB Output is correct
76 Correct 19 ms 440 KB Output is correct
77 Correct 54 ms 572 KB Output is correct
78 Correct 56 ms 596 KB Output is correct
79 Correct 54 ms 568 KB Output is correct
80 Correct 54 ms 708 KB Output is correct
81 Correct 53 ms 588 KB Output is correct
82 Correct 56 ms 708 KB Output is correct
83 Correct 53 ms 532 KB Output is correct
84 Correct 54 ms 592 KB Output is correct
85 Correct 53 ms 668 KB Output is correct
86 Correct 54 ms 724 KB Output is correct
87 Correct 55 ms 560 KB Output is correct
88 Correct 55 ms 496 KB Output is correct
89 Correct 54 ms 688 KB Output is correct
90 Correct 54 ms 616 KB Output is correct
91 Correct 54 ms 492 KB Output is correct
92 Correct 54 ms 524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 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 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 1 ms 324 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 18 ms 468 KB Output is correct
66 Correct 18 ms 504 KB Output is correct
67 Correct 19 ms 468 KB Output is correct
68 Correct 18 ms 432 KB Output is correct
69 Correct 18 ms 476 KB Output is correct
70 Correct 18 ms 468 KB Output is correct
71 Correct 18 ms 468 KB Output is correct
72 Correct 19 ms 444 KB Output is correct
73 Correct 19 ms 516 KB Output is correct
74 Correct 20 ms 488 KB Output is correct
75 Correct 18 ms 468 KB Output is correct
76 Correct 19 ms 440 KB Output is correct
77 Correct 54 ms 572 KB Output is correct
78 Correct 56 ms 596 KB Output is correct
79 Correct 54 ms 568 KB Output is correct
80 Correct 54 ms 708 KB Output is correct
81 Correct 53 ms 588 KB Output is correct
82 Correct 56 ms 708 KB Output is correct
83 Correct 53 ms 532 KB Output is correct
84 Correct 54 ms 592 KB Output is correct
85 Correct 53 ms 668 KB Output is correct
86 Correct 54 ms 724 KB Output is correct
87 Correct 55 ms 560 KB Output is correct
88 Correct 55 ms 496 KB Output is correct
89 Correct 54 ms 688 KB Output is correct
90 Correct 54 ms 616 KB Output is correct
91 Correct 54 ms 492 KB Output is correct
92 Correct 54 ms 524 KB Output is correct
93 Correct 1430 ms 3320 KB Output is correct
94 Correct 1412 ms 3392 KB Output is correct
95 Correct 1468 ms 3468 KB Output is correct
96 Correct 1423 ms 3416 KB Output is correct
97 Correct 1437 ms 3384 KB Output is correct
98 Correct 1456 ms 3460 KB Output is correct
99 Correct 160 ms 1100 KB Output is correct
100 Correct 159 ms 1016 KB Output is correct
101 Correct 159 ms 884 KB Output is correct
102 Correct 163 ms 840 KB Output is correct
103 Correct 479 ms 1872 KB Output is correct
104 Correct 489 ms 1824 KB Output is correct
105 Correct 474 ms 1716 KB Output is correct
106 Correct 476 ms 1476 KB Output is correct
107 Correct 1442 ms 3388 KB Output is correct
108 Correct 1444 ms 2960 KB Output is correct
109 Correct 1416 ms 2860 KB Output is correct
110 Correct 1444 ms 2632 KB Output is correct
111 Correct 157 ms 944 KB Output is correct
112 Correct 159 ms 808 KB Output is correct
113 Correct 158 ms 832 KB Output is correct
114 Correct 165 ms 1080 KB Output is correct
115 Correct 158 ms 1088 KB Output is correct
116 Correct 160 ms 900 KB Output is correct
117 Correct 158 ms 844 KB Output is correct
118 Correct 160 ms 1072 KB Output is correct
119 Correct 157 ms 844 KB Output is correct
120 Correct 159 ms 808 KB Output is correct
121 Correct 157 ms 824 KB Output is correct
122 Correct 472 ms 1528 KB Output is correct
123 Correct 484 ms 1572 KB Output is correct
124 Correct 472 ms 1484 KB Output is correct
125 Correct 480 ms 1408 KB Output is correct
126 Correct 485 ms 1392 KB Output is correct
127 Correct 468 ms 1356 KB Output is correct
128 Correct 479 ms 1348 KB Output is correct
129 Correct 473 ms 1464 KB Output is correct
130 Correct 477 ms 1500 KB Output is correct
131 Correct 486 ms 1796 KB Output is correct
132 Correct 471 ms 1740 KB Output is correct
133 Correct 476 ms 1612 KB Output is correct
134 Correct 476 ms 1456 KB Output is correct
135 Correct 465 ms 1968 KB Output is correct
136 Correct 480 ms 1472 KB Output is correct
137 Correct 476 ms 1424 KB Output is correct
138 Correct 480 ms 1484 KB Output is correct
139 Correct 472 ms 1836 KB Output is correct
140 Correct 475 ms 1684 KB Output is correct
141 Correct 474 ms 1504 KB Output is correct
142 Correct 1404 ms 2708 KB Output is correct
143 Correct 1430 ms 2496 KB Output is correct
144 Correct 1410 ms 2656 KB Output is correct
145 Correct 1412 ms 2400 KB Output is correct
146 Correct 1414 ms 2384 KB Output is correct
147 Correct 1408 ms 2380 KB Output is correct
148 Correct 1408 ms 2596 KB Output is correct
149 Correct 1417 ms 2560 KB Output is correct
150 Correct 1407 ms 2476 KB Output is correct
151 Correct 1410 ms 2524 KB Output is correct
152 Correct 1426 ms 2656 KB Output is correct
153 Correct 1416 ms 3484 KB Output is correct
154 Correct 1416 ms 3500 KB Output is correct
155 Correct 1423 ms 2944 KB Output is correct
156 Correct 1414 ms 2576 KB Output is correct
157 Correct 1407 ms 2936 KB Output is correct
158 Correct 1413 ms 2716 KB Output is correct
159 Correct 1419 ms 3476 KB Output is correct
160 Correct 1412 ms 2744 KB Output is correct
161 Correct 1408 ms 2752 KB Output is correct
162 Correct 1430 ms 3444 KB Output is correct
163 Correct 1421 ms 2928 KB Output is correct
164 Correct 1436 ms 2676 KB Output is correct
165 Correct 1468 ms 2816 KB Output is correct
166 Correct 1417 ms 2524 KB Output is correct
167 Correct 1405 ms 2532 KB Output is correct