Submission #608844

# Submission time Handle Problem Language Result Execution time Memory
608844 2022-07-27T10:46:43 Z 1bin Amusement Park (CEOI19_amusementpark) C++14
100 / 100
1815 ms 308860 KB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
const ll mod = 998244353;
ll n, m, a, b, e[18];
map<int, ll> dp[1 << 18];

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a >> b; a--; b--;
        e[a] |= 1 << b;
        e[b] |= 1 << a;
    }
    dp[0][(1 << n) - 1] = 1;
    for(int a = 0; a < 1 << n; a++)
        for(auto& [b, x] : dp[a]){
            for(int i = 0; i < n; i++){
                if(!(b & (1 << i))) continue;
                int nxa = a | (1 << i);
                int nxb = (b & ((1 << n) - 1 - ((1 << (i + 1)) - 1))) | (e[i] & ((1 << n) - 1 - nxa));
                dp[nxa][nxb] += x; dp[nxa][nxb] %= mod;
            }
        }
    cout << dp[(1 << n) - 1][0] * m % mod * (mod + 1) / 2 % mod;
    return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:22:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   22 |         for(auto& [b, x] : dp[a]){
      |                   ^
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12628 KB Output is correct
2 Correct 6 ms 12628 KB Output is correct
3 Correct 9 ms 12628 KB Output is correct
4 Correct 6 ms 12636 KB Output is correct
5 Correct 7 ms 12568 KB Output is correct
6 Correct 7 ms 12628 KB Output is correct
7 Correct 8 ms 12636 KB Output is correct
8 Correct 8 ms 12628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12628 KB Output is correct
2 Correct 6 ms 12628 KB Output is correct
3 Correct 9 ms 12628 KB Output is correct
4 Correct 6 ms 12636 KB Output is correct
5 Correct 7 ms 12568 KB Output is correct
6 Correct 7 ms 12628 KB Output is correct
7 Correct 8 ms 12636 KB Output is correct
8 Correct 8 ms 12628 KB Output is correct
9 Correct 6 ms 12628 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 8 ms 12532 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 8 ms 12600 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 6 ms 12628 KB Output is correct
18 Correct 7 ms 12628 KB Output is correct
19 Correct 7 ms 12628 KB Output is correct
20 Correct 7 ms 12628 KB Output is correct
21 Correct 7 ms 12628 KB Output is correct
22 Correct 8 ms 12628 KB Output is correct
23 Correct 7 ms 12628 KB Output is correct
24 Correct 6 ms 12628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12628 KB Output is correct
2 Correct 6 ms 12628 KB Output is correct
3 Correct 9 ms 12628 KB Output is correct
4 Correct 6 ms 12636 KB Output is correct
5 Correct 7 ms 12568 KB Output is correct
6 Correct 7 ms 12628 KB Output is correct
7 Correct 8 ms 12636 KB Output is correct
8 Correct 8 ms 12628 KB Output is correct
9 Correct 6 ms 12628 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 8 ms 12532 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 8 ms 12600 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 6 ms 12628 KB Output is correct
18 Correct 7 ms 12628 KB Output is correct
19 Correct 7 ms 12628 KB Output is correct
20 Correct 7 ms 12628 KB Output is correct
21 Correct 7 ms 12628 KB Output is correct
22 Correct 8 ms 12628 KB Output is correct
23 Correct 7 ms 12628 KB Output is correct
24 Correct 6 ms 12628 KB Output is correct
25 Correct 7 ms 12628 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 7 ms 12628 KB Output is correct
28 Correct 7 ms 12640 KB Output is correct
29 Correct 7 ms 12628 KB Output is correct
30 Correct 7 ms 12628 KB Output is correct
31 Correct 8 ms 12628 KB Output is correct
32 Correct 7 ms 12632 KB Output is correct
33 Correct 7 ms 12628 KB Output is correct
34 Correct 7 ms 12628 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 7 ms 12664 KB Output is correct
37 Correct 6 ms 12628 KB Output is correct
38 Correct 6 ms 12576 KB Output is correct
39 Correct 7 ms 12636 KB Output is correct
40 Correct 6 ms 12628 KB Output is correct
41 Correct 7 ms 12628 KB Output is correct
42 Correct 8 ms 12628 KB Output is correct
43 Correct 7 ms 12628 KB Output is correct
44 Correct 8 ms 12632 KB Output is correct
45 Correct 8 ms 12628 KB Output is correct
46 Correct 7 ms 12628 KB Output is correct
47 Correct 7 ms 12628 KB Output is correct
48 Correct 7 ms 12628 KB Output is correct
49 Correct 7 ms 12628 KB Output is correct
50 Correct 6 ms 12628 KB Output is correct
51 Correct 6 ms 12628 KB Output is correct
52 Correct 7 ms 12628 KB Output is correct
53 Correct 7 ms 12756 KB Output is correct
54 Correct 7 ms 12756 KB Output is correct
55 Correct 7 ms 12764 KB Output is correct
56 Correct 7 ms 12888 KB Output is correct
57 Correct 7 ms 12756 KB Output is correct
58 Correct 9 ms 12756 KB Output is correct
59 Correct 7 ms 12756 KB Output is correct
60 Correct 7 ms 12632 KB Output is correct
61 Correct 8 ms 12756 KB Output is correct
62 Correct 8 ms 12716 KB Output is correct
63 Correct 7 ms 12756 KB Output is correct
64 Correct 9 ms 12756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12628 KB Output is correct
2 Correct 6 ms 12628 KB Output is correct
3 Correct 9 ms 12628 KB Output is correct
4 Correct 6 ms 12636 KB Output is correct
5 Correct 7 ms 12568 KB Output is correct
6 Correct 7 ms 12628 KB Output is correct
7 Correct 8 ms 12636 KB Output is correct
8 Correct 8 ms 12628 KB Output is correct
9 Correct 6 ms 12628 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 8 ms 12532 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 8 ms 12600 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 6 ms 12628 KB Output is correct
18 Correct 7 ms 12628 KB Output is correct
19 Correct 7 ms 12628 KB Output is correct
20 Correct 7 ms 12628 KB Output is correct
21 Correct 7 ms 12628 KB Output is correct
22 Correct 8 ms 12628 KB Output is correct
23 Correct 7 ms 12628 KB Output is correct
24 Correct 6 ms 12628 KB Output is correct
25 Correct 7 ms 12628 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 7 ms 12628 KB Output is correct
28 Correct 7 ms 12640 KB Output is correct
29 Correct 7 ms 12628 KB Output is correct
30 Correct 7 ms 12628 KB Output is correct
31 Correct 8 ms 12628 KB Output is correct
32 Correct 7 ms 12632 KB Output is correct
33 Correct 7 ms 12628 KB Output is correct
34 Correct 7 ms 12628 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 7 ms 12664 KB Output is correct
37 Correct 6 ms 12628 KB Output is correct
38 Correct 6 ms 12576 KB Output is correct
39 Correct 7 ms 12636 KB Output is correct
40 Correct 6 ms 12628 KB Output is correct
41 Correct 7 ms 12628 KB Output is correct
42 Correct 8 ms 12628 KB Output is correct
43 Correct 7 ms 12628 KB Output is correct
44 Correct 8 ms 12632 KB Output is correct
45 Correct 8 ms 12628 KB Output is correct
46 Correct 7 ms 12628 KB Output is correct
47 Correct 7 ms 12628 KB Output is correct
48 Correct 7 ms 12628 KB Output is correct
49 Correct 7 ms 12628 KB Output is correct
50 Correct 6 ms 12628 KB Output is correct
51 Correct 6 ms 12628 KB Output is correct
52 Correct 7 ms 12628 KB Output is correct
53 Correct 7 ms 12756 KB Output is correct
54 Correct 7 ms 12756 KB Output is correct
55 Correct 7 ms 12764 KB Output is correct
56 Correct 7 ms 12888 KB Output is correct
57 Correct 7 ms 12756 KB Output is correct
58 Correct 9 ms 12756 KB Output is correct
59 Correct 7 ms 12756 KB Output is correct
60 Correct 7 ms 12632 KB Output is correct
61 Correct 8 ms 12756 KB Output is correct
62 Correct 8 ms 12716 KB Output is correct
63 Correct 7 ms 12756 KB Output is correct
64 Correct 9 ms 12756 KB Output is correct
65 Correct 33 ms 18776 KB Output is correct
66 Correct 52 ms 20820 KB Output is correct
67 Correct 44 ms 20072 KB Output is correct
68 Correct 39 ms 19712 KB Output is correct
69 Correct 14 ms 15188 KB Output is correct
70 Correct 16 ms 15700 KB Output is correct
71 Correct 15 ms 15772 KB Output is correct
72 Correct 16 ms 15700 KB Output is correct
73 Correct 18 ms 15900 KB Output is correct
74 Correct 16 ms 15960 KB Output is correct
75 Correct 16 ms 15828 KB Output is correct
76 Correct 15 ms 15900 KB Output is correct
77 Correct 72 ms 27656 KB Output is correct
78 Correct 81 ms 29208 KB Output is correct
79 Correct 108 ms 33380 KB Output is correct
80 Correct 90 ms 29660 KB Output is correct
81 Correct 105 ms 31472 KB Output is correct
82 Correct 98 ms 29552 KB Output is correct
83 Correct 91 ms 28916 KB Output is correct
84 Correct 62 ms 24144 KB Output is correct
85 Correct 24 ms 17884 KB Output is correct
86 Correct 27 ms 19284 KB Output is correct
87 Correct 28 ms 19192 KB Output is correct
88 Correct 26 ms 19256 KB Output is correct
89 Correct 30 ms 19540 KB Output is correct
90 Correct 29 ms 19748 KB Output is correct
91 Correct 28 ms 19552 KB Output is correct
92 Correct 26 ms 19524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12628 KB Output is correct
2 Correct 6 ms 12628 KB Output is correct
3 Correct 9 ms 12628 KB Output is correct
4 Correct 6 ms 12636 KB Output is correct
5 Correct 7 ms 12568 KB Output is correct
6 Correct 7 ms 12628 KB Output is correct
7 Correct 8 ms 12636 KB Output is correct
8 Correct 8 ms 12628 KB Output is correct
9 Correct 6 ms 12628 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 8 ms 12532 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 8 ms 12600 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 6 ms 12628 KB Output is correct
18 Correct 7 ms 12628 KB Output is correct
19 Correct 7 ms 12628 KB Output is correct
20 Correct 7 ms 12628 KB Output is correct
21 Correct 7 ms 12628 KB Output is correct
22 Correct 8 ms 12628 KB Output is correct
23 Correct 7 ms 12628 KB Output is correct
24 Correct 6 ms 12628 KB Output is correct
25 Correct 7 ms 12628 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 7 ms 12628 KB Output is correct
28 Correct 7 ms 12640 KB Output is correct
29 Correct 7 ms 12628 KB Output is correct
30 Correct 7 ms 12628 KB Output is correct
31 Correct 8 ms 12628 KB Output is correct
32 Correct 7 ms 12632 KB Output is correct
33 Correct 7 ms 12628 KB Output is correct
34 Correct 7 ms 12628 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 7 ms 12664 KB Output is correct
37 Correct 6 ms 12628 KB Output is correct
38 Correct 6 ms 12576 KB Output is correct
39 Correct 7 ms 12636 KB Output is correct
40 Correct 6 ms 12628 KB Output is correct
41 Correct 7 ms 12628 KB Output is correct
42 Correct 8 ms 12628 KB Output is correct
43 Correct 7 ms 12628 KB Output is correct
44 Correct 8 ms 12632 KB Output is correct
45 Correct 8 ms 12628 KB Output is correct
46 Correct 7 ms 12628 KB Output is correct
47 Correct 7 ms 12628 KB Output is correct
48 Correct 7 ms 12628 KB Output is correct
49 Correct 7 ms 12628 KB Output is correct
50 Correct 6 ms 12628 KB Output is correct
51 Correct 6 ms 12628 KB Output is correct
52 Correct 7 ms 12628 KB Output is correct
53 Correct 7 ms 12756 KB Output is correct
54 Correct 7 ms 12756 KB Output is correct
55 Correct 7 ms 12764 KB Output is correct
56 Correct 7 ms 12888 KB Output is correct
57 Correct 7 ms 12756 KB Output is correct
58 Correct 9 ms 12756 KB Output is correct
59 Correct 7 ms 12756 KB Output is correct
60 Correct 7 ms 12632 KB Output is correct
61 Correct 8 ms 12756 KB Output is correct
62 Correct 8 ms 12716 KB Output is correct
63 Correct 7 ms 12756 KB Output is correct
64 Correct 9 ms 12756 KB Output is correct
65 Correct 33 ms 18776 KB Output is correct
66 Correct 52 ms 20820 KB Output is correct
67 Correct 44 ms 20072 KB Output is correct
68 Correct 39 ms 19712 KB Output is correct
69 Correct 14 ms 15188 KB Output is correct
70 Correct 16 ms 15700 KB Output is correct
71 Correct 15 ms 15772 KB Output is correct
72 Correct 16 ms 15700 KB Output is correct
73 Correct 18 ms 15900 KB Output is correct
74 Correct 16 ms 15960 KB Output is correct
75 Correct 16 ms 15828 KB Output is correct
76 Correct 15 ms 15900 KB Output is correct
77 Correct 72 ms 27656 KB Output is correct
78 Correct 81 ms 29208 KB Output is correct
79 Correct 108 ms 33380 KB Output is correct
80 Correct 90 ms 29660 KB Output is correct
81 Correct 105 ms 31472 KB Output is correct
82 Correct 98 ms 29552 KB Output is correct
83 Correct 91 ms 28916 KB Output is correct
84 Correct 62 ms 24144 KB Output is correct
85 Correct 24 ms 17884 KB Output is correct
86 Correct 27 ms 19284 KB Output is correct
87 Correct 28 ms 19192 KB Output is correct
88 Correct 26 ms 19256 KB Output is correct
89 Correct 30 ms 19540 KB Output is correct
90 Correct 29 ms 19748 KB Output is correct
91 Correct 28 ms 19552 KB Output is correct
92 Correct 26 ms 19524 KB Output is correct
93 Correct 265 ms 75112 KB Output is correct
94 Correct 108 ms 39020 KB Output is correct
95 Correct 51 ms 31144 KB Output is correct
96 Correct 276 ms 79180 KB Output is correct
97 Correct 285 ms 78412 KB Output is correct
98 Correct 274 ms 73984 KB Output is correct
99 Correct 96 ms 35024 KB Output is correct
100 Correct 160 ms 47744 KB Output is correct
101 Correct 268 ms 58172 KB Output is correct
102 Correct 263 ms 60728 KB Output is correct
103 Correct 19 ms 20820 KB Output is correct
104 Correct 21 ms 21500 KB Output is correct
105 Correct 78 ms 36812 KB Output is correct
106 Correct 352 ms 84424 KB Output is correct
107 Correct 44 ms 28964 KB Output is correct
108 Correct 149 ms 68528 KB Output is correct
109 Correct 826 ms 170564 KB Output is correct
110 Correct 1815 ms 308860 KB Output is correct
111 Correct 263 ms 60476 KB Output is correct
112 Correct 223 ms 51360 KB Output is correct
113 Correct 213 ms 49100 KB Output is correct
114 Correct 48 ms 24004 KB Output is correct
115 Correct 67 ms 26668 KB Output is correct
116 Correct 53 ms 26656 KB Output is correct
117 Correct 49 ms 26664 KB Output is correct
118 Correct 65 ms 27412 KB Output is correct
119 Correct 60 ms 27444 KB Output is correct
120 Correct 59 ms 27468 KB Output is correct
121 Correct 65 ms 27488 KB Output is correct
122 Correct 429 ms 93560 KB Output is correct
123 Correct 648 ms 122848 KB Output is correct
124 Correct 637 ms 115796 KB Output is correct
125 Correct 552 ms 106528 KB Output is correct
126 Correct 519 ms 95380 KB Output is correct
127 Correct 332 ms 68404 KB Output is correct
128 Correct 198 ms 48452 KB Output is correct
129 Correct 119 ms 34740 KB Output is correct
130 Correct 32 ms 20732 KB Output is correct
131 Correct 91 ms 36168 KB Output is correct
132 Correct 115 ms 42328 KB Output is correct
133 Correct 119 ms 42484 KB Output is correct
134 Correct 105 ms 42364 KB Output is correct
135 Correct 127 ms 44108 KB Output is correct
136 Correct 144 ms 44108 KB Output is correct
137 Correct 123 ms 44120 KB Output is correct
138 Correct 113 ms 44100 KB Output is correct
139 Correct 138 ms 43820 KB Output is correct
140 Correct 130 ms 43908 KB Output is correct
141 Correct 112 ms 43828 KB Output is correct
142 Correct 1497 ms 258232 KB Output is correct
143 Correct 1478 ms 239612 KB Output is correct
144 Correct 1026 ms 176032 KB Output is correct
145 Correct 742 ms 130960 KB Output is correct
146 Correct 332 ms 73904 KB Output is correct
147 Correct 69 ms 28924 KB Output is correct
148 Correct 1689 ms 244372 KB Output is correct
149 Correct 1461 ms 238484 KB Output is correct
150 Correct 1685 ms 271352 KB Output is correct
151 Correct 242 ms 76524 KB Output is correct
152 Correct 254 ms 80588 KB Output is correct
153 Correct 277 ms 79180 KB Output is correct
154 Correct 332 ms 79212 KB Output is correct
155 Correct 294 ms 79296 KB Output is correct
156 Correct 298 ms 79188 KB Output is correct
157 Correct 305 ms 79392 KB Output is correct
158 Correct 282 ms 79284 KB Output is correct
159 Correct 306 ms 79012 KB Output is correct
160 Correct 294 ms 78980 KB Output is correct
161 Correct 242 ms 79156 KB Output is correct
162 Correct 284 ms 76720 KB Output is correct
163 Correct 361 ms 76700 KB Output is correct
164 Correct 304 ms 76828 KB Output is correct
165 Correct 318 ms 76884 KB Output is correct
166 Correct 246 ms 76732 KB Output is correct
167 Correct 252 ms 76712 KB Output is correct