Submission #572963

# Submission time Handle Problem Language Result Execution time Memory
572963 2022-06-05T15:04:57 Z piOOE Amusement Park (CEOI19_amusementpark) C++17
100 / 100
1556 ms 234720 KB
#include <bits/stdc++.h>

using namespace std;

#define sz(x) ((int)size(x))
#define all(x) begin(x), end(x)
#define trace(x) cout << #x << ": " << (x) << endl;

typedef long long ll;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int rand(int l, int r) { return (int) ((ll) rnd() % (r - l + 1)) + l; }

const int N = 18, MOD = 998244353;

int adj[N];

map<int, int> dp[1 << N];

int add(int a, int b) {
    return a + b < MOD ? a + b : a + b - MOD;
}

int mul(int a, int b) {
    return a * (ll) b % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        adj[a] |= (1 << b);
        adj[b] |= (1 << a);
    }
    dp[0][(1 << n) - 1] = 1;
    for (int a = 0; a < (1 << n); ++a) {
        for (auto [b, cnt] : dp[a]) {
            for (int i = 0; i < n; ++i) {
                if (b & 1 << i) {
                    int newb = b & (1 << n) - (1 << (i + 1));
                    newb = newb | ((adj[i] | a) ^ a);
                    dp[a ^ (1 << i)][newb] = add(dp[a ^ (1 << i)][newb], cnt);
                }
            }
        }
    }
    cout << mul(dp[(1 << n) - 1][0], mul(m, (MOD + 1) / 2));
    return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:46:45: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   46 |                     int newb = b & (1 << n) - (1 << (i + 1));
      |                                    ~~~~~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 12584 KB Output is correct
2 Correct 7 ms 12628 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 6 ms 12632 KB Output is correct
5 Correct 7 ms 12628 KB Output is correct
6 Correct 6 ms 12628 KB Output is correct
7 Correct 8 ms 12628 KB Output is correct
8 Correct 6 ms 12628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 12584 KB Output is correct
2 Correct 7 ms 12628 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 6 ms 12632 KB Output is correct
5 Correct 7 ms 12628 KB Output is correct
6 Correct 6 ms 12628 KB Output is correct
7 Correct 8 ms 12628 KB Output is correct
8 Correct 6 ms 12628 KB Output is correct
9 Correct 6 ms 12640 KB Output is correct
10 Correct 7 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 7 ms 12628 KB Output is correct
13 Correct 6 ms 12628 KB Output is correct
14 Correct 7 ms 12628 KB Output is correct
15 Correct 6 ms 12628 KB Output is correct
16 Correct 6 ms 12628 KB Output is correct
17 Correct 7 ms 12596 KB Output is correct
18 Correct 6 ms 12560 KB Output is correct
19 Correct 8 ms 12628 KB Output is correct
20 Correct 7 ms 12628 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 6 ms 12552 KB Output is correct
23 Correct 6 ms 12508 KB Output is correct
24 Correct 6 ms 12632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 12584 KB Output is correct
2 Correct 7 ms 12628 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 6 ms 12632 KB Output is correct
5 Correct 7 ms 12628 KB Output is correct
6 Correct 6 ms 12628 KB Output is correct
7 Correct 8 ms 12628 KB Output is correct
8 Correct 6 ms 12628 KB Output is correct
9 Correct 6 ms 12640 KB Output is correct
10 Correct 7 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 7 ms 12628 KB Output is correct
13 Correct 6 ms 12628 KB Output is correct
14 Correct 7 ms 12628 KB Output is correct
15 Correct 6 ms 12628 KB Output is correct
16 Correct 6 ms 12628 KB Output is correct
17 Correct 7 ms 12596 KB Output is correct
18 Correct 6 ms 12560 KB Output is correct
19 Correct 8 ms 12628 KB Output is correct
20 Correct 7 ms 12628 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 6 ms 12552 KB Output is correct
23 Correct 6 ms 12508 KB Output is correct
24 Correct 6 ms 12632 KB Output is correct
25 Correct 7 ms 12628 KB Output is correct
26 Correct 6 ms 12628 KB Output is correct
27 Correct 6 ms 12628 KB Output is correct
28 Correct 6 ms 12560 KB Output is correct
29 Correct 7 ms 12572 KB Output is correct
30 Correct 7 ms 12512 KB Output is correct
31 Correct 6 ms 12628 KB Output is correct
32 Correct 7 ms 12628 KB Output is correct
33 Correct 7 ms 12628 KB Output is correct
34 Correct 6 ms 12628 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 7 ms 12628 KB Output is correct
37 Correct 7 ms 12628 KB Output is correct
38 Correct 7 ms 12640 KB Output is correct
39 Correct 6 ms 12628 KB Output is correct
40 Correct 7 ms 12628 KB Output is correct
41 Correct 7 ms 12628 KB Output is correct
42 Correct 7 ms 12596 KB Output is correct
43 Correct 7 ms 12636 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 6 ms 12628 KB Output is correct
46 Correct 6 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 6 ms 12628 KB Output is correct
50 Correct 7 ms 12628 KB Output is correct
51 Correct 7 ms 12628 KB Output is correct
52 Correct 8 ms 12628 KB Output is correct
53 Correct 7 ms 12712 KB Output is correct
54 Correct 6 ms 12720 KB Output is correct
55 Correct 7 ms 12628 KB Output is correct
56 Correct 7 ms 12756 KB Output is correct
57 Correct 7 ms 12804 KB Output is correct
58 Correct 6 ms 12628 KB Output is correct
59 Correct 7 ms 12648 KB Output is correct
60 Correct 6 ms 12628 KB Output is correct
61 Correct 6 ms 12724 KB Output is correct
62 Correct 7 ms 12628 KB Output is correct
63 Correct 7 ms 12628 KB Output is correct
64 Correct 6 ms 12628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 12584 KB Output is correct
2 Correct 7 ms 12628 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 6 ms 12632 KB Output is correct
5 Correct 7 ms 12628 KB Output is correct
6 Correct 6 ms 12628 KB Output is correct
7 Correct 8 ms 12628 KB Output is correct
8 Correct 6 ms 12628 KB Output is correct
9 Correct 6 ms 12640 KB Output is correct
10 Correct 7 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 7 ms 12628 KB Output is correct
13 Correct 6 ms 12628 KB Output is correct
14 Correct 7 ms 12628 KB Output is correct
15 Correct 6 ms 12628 KB Output is correct
16 Correct 6 ms 12628 KB Output is correct
17 Correct 7 ms 12596 KB Output is correct
18 Correct 6 ms 12560 KB Output is correct
19 Correct 8 ms 12628 KB Output is correct
20 Correct 7 ms 12628 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 6 ms 12552 KB Output is correct
23 Correct 6 ms 12508 KB Output is correct
24 Correct 6 ms 12632 KB Output is correct
25 Correct 7 ms 12628 KB Output is correct
26 Correct 6 ms 12628 KB Output is correct
27 Correct 6 ms 12628 KB Output is correct
28 Correct 6 ms 12560 KB Output is correct
29 Correct 7 ms 12572 KB Output is correct
30 Correct 7 ms 12512 KB Output is correct
31 Correct 6 ms 12628 KB Output is correct
32 Correct 7 ms 12628 KB Output is correct
33 Correct 7 ms 12628 KB Output is correct
34 Correct 6 ms 12628 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 7 ms 12628 KB Output is correct
37 Correct 7 ms 12628 KB Output is correct
38 Correct 7 ms 12640 KB Output is correct
39 Correct 6 ms 12628 KB Output is correct
40 Correct 7 ms 12628 KB Output is correct
41 Correct 7 ms 12628 KB Output is correct
42 Correct 7 ms 12596 KB Output is correct
43 Correct 7 ms 12636 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 6 ms 12628 KB Output is correct
46 Correct 6 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 6 ms 12628 KB Output is correct
50 Correct 7 ms 12628 KB Output is correct
51 Correct 7 ms 12628 KB Output is correct
52 Correct 8 ms 12628 KB Output is correct
53 Correct 7 ms 12712 KB Output is correct
54 Correct 6 ms 12720 KB Output is correct
55 Correct 7 ms 12628 KB Output is correct
56 Correct 7 ms 12756 KB Output is correct
57 Correct 7 ms 12804 KB Output is correct
58 Correct 6 ms 12628 KB Output is correct
59 Correct 7 ms 12648 KB Output is correct
60 Correct 6 ms 12628 KB Output is correct
61 Correct 6 ms 12724 KB Output is correct
62 Correct 7 ms 12628 KB Output is correct
63 Correct 7 ms 12628 KB Output is correct
64 Correct 6 ms 12628 KB Output is correct
65 Correct 27 ms 17208 KB Output is correct
66 Correct 37 ms 18772 KB Output is correct
67 Correct 34 ms 18280 KB Output is correct
68 Correct 37 ms 17944 KB Output is correct
69 Correct 12 ms 14556 KB Output is correct
70 Correct 15 ms 14932 KB Output is correct
71 Correct 14 ms 14932 KB Output is correct
72 Correct 13 ms 14996 KB Output is correct
73 Correct 14 ms 15060 KB Output is correct
74 Correct 14 ms 14976 KB Output is correct
75 Correct 14 ms 15060 KB Output is correct
76 Correct 14 ms 15060 KB Output is correct
77 Correct 59 ms 23724 KB Output is correct
78 Correct 67 ms 25036 KB Output is correct
79 Correct 90 ms 28192 KB Output is correct
80 Correct 77 ms 25376 KB Output is correct
81 Correct 83 ms 26700 KB Output is correct
82 Correct 74 ms 25280 KB Output is correct
83 Correct 73 ms 24848 KB Output is correct
84 Correct 53 ms 21308 KB Output is correct
85 Correct 19 ms 16632 KB Output is correct
86 Correct 22 ms 17520 KB Output is correct
87 Correct 25 ms 17632 KB Output is correct
88 Correct 22 ms 17548 KB Output is correct
89 Correct 24 ms 17780 KB Output is correct
90 Correct 23 ms 17748 KB Output is correct
91 Correct 23 ms 17848 KB Output is correct
92 Correct 23 ms 17748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 12584 KB Output is correct
2 Correct 7 ms 12628 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 6 ms 12632 KB Output is correct
5 Correct 7 ms 12628 KB Output is correct
6 Correct 6 ms 12628 KB Output is correct
7 Correct 8 ms 12628 KB Output is correct
8 Correct 6 ms 12628 KB Output is correct
9 Correct 6 ms 12640 KB Output is correct
10 Correct 7 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 7 ms 12628 KB Output is correct
13 Correct 6 ms 12628 KB Output is correct
14 Correct 7 ms 12628 KB Output is correct
15 Correct 6 ms 12628 KB Output is correct
16 Correct 6 ms 12628 KB Output is correct
17 Correct 7 ms 12596 KB Output is correct
18 Correct 6 ms 12560 KB Output is correct
19 Correct 8 ms 12628 KB Output is correct
20 Correct 7 ms 12628 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 6 ms 12552 KB Output is correct
23 Correct 6 ms 12508 KB Output is correct
24 Correct 6 ms 12632 KB Output is correct
25 Correct 7 ms 12628 KB Output is correct
26 Correct 6 ms 12628 KB Output is correct
27 Correct 6 ms 12628 KB Output is correct
28 Correct 6 ms 12560 KB Output is correct
29 Correct 7 ms 12572 KB Output is correct
30 Correct 7 ms 12512 KB Output is correct
31 Correct 6 ms 12628 KB Output is correct
32 Correct 7 ms 12628 KB Output is correct
33 Correct 7 ms 12628 KB Output is correct
34 Correct 6 ms 12628 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 7 ms 12628 KB Output is correct
37 Correct 7 ms 12628 KB Output is correct
38 Correct 7 ms 12640 KB Output is correct
39 Correct 6 ms 12628 KB Output is correct
40 Correct 7 ms 12628 KB Output is correct
41 Correct 7 ms 12628 KB Output is correct
42 Correct 7 ms 12596 KB Output is correct
43 Correct 7 ms 12636 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 6 ms 12628 KB Output is correct
46 Correct 6 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 6 ms 12628 KB Output is correct
50 Correct 7 ms 12628 KB Output is correct
51 Correct 7 ms 12628 KB Output is correct
52 Correct 8 ms 12628 KB Output is correct
53 Correct 7 ms 12712 KB Output is correct
54 Correct 6 ms 12720 KB Output is correct
55 Correct 7 ms 12628 KB Output is correct
56 Correct 7 ms 12756 KB Output is correct
57 Correct 7 ms 12804 KB Output is correct
58 Correct 6 ms 12628 KB Output is correct
59 Correct 7 ms 12648 KB Output is correct
60 Correct 6 ms 12628 KB Output is correct
61 Correct 6 ms 12724 KB Output is correct
62 Correct 7 ms 12628 KB Output is correct
63 Correct 7 ms 12628 KB Output is correct
64 Correct 6 ms 12628 KB Output is correct
65 Correct 27 ms 17208 KB Output is correct
66 Correct 37 ms 18772 KB Output is correct
67 Correct 34 ms 18280 KB Output is correct
68 Correct 37 ms 17944 KB Output is correct
69 Correct 12 ms 14556 KB Output is correct
70 Correct 15 ms 14932 KB Output is correct
71 Correct 14 ms 14932 KB Output is correct
72 Correct 13 ms 14996 KB Output is correct
73 Correct 14 ms 15060 KB Output is correct
74 Correct 14 ms 14976 KB Output is correct
75 Correct 14 ms 15060 KB Output is correct
76 Correct 14 ms 15060 KB Output is correct
77 Correct 59 ms 23724 KB Output is correct
78 Correct 67 ms 25036 KB Output is correct
79 Correct 90 ms 28192 KB Output is correct
80 Correct 77 ms 25376 KB Output is correct
81 Correct 83 ms 26700 KB Output is correct
82 Correct 74 ms 25280 KB Output is correct
83 Correct 73 ms 24848 KB Output is correct
84 Correct 53 ms 21308 KB Output is correct
85 Correct 19 ms 16632 KB Output is correct
86 Correct 22 ms 17520 KB Output is correct
87 Correct 25 ms 17632 KB Output is correct
88 Correct 22 ms 17548 KB Output is correct
89 Correct 24 ms 17780 KB Output is correct
90 Correct 23 ms 17748 KB Output is correct
91 Correct 23 ms 17848 KB Output is correct
92 Correct 23 ms 17748 KB Output is correct
93 Correct 218 ms 59552 KB Output is correct
94 Correct 71 ms 32424 KB Output is correct
95 Correct 41 ms 26444 KB Output is correct
96 Correct 212 ms 62600 KB Output is correct
97 Correct 218 ms 62032 KB Output is correct
98 Correct 194 ms 58688 KB Output is correct
99 Correct 78 ms 29408 KB Output is correct
100 Correct 135 ms 38828 KB Output is correct
101 Correct 207 ms 46796 KB Output is correct
102 Correct 221 ms 48732 KB Output is correct
103 Correct 19 ms 18680 KB Output is correct
104 Correct 19 ms 19256 KB Output is correct
105 Correct 63 ms 30852 KB Output is correct
106 Correct 285 ms 66376 KB Output is correct
107 Correct 30 ms 24908 KB Output is correct
108 Correct 133 ms 54628 KB Output is correct
109 Correct 661 ms 131148 KB Output is correct
110 Correct 1556 ms 234720 KB Output is correct
111 Correct 231 ms 48560 KB Output is correct
112 Correct 180 ms 41640 KB Output is correct
113 Correct 170 ms 40016 KB Output is correct
114 Correct 33 ms 21068 KB Output is correct
115 Correct 46 ms 23180 KB Output is correct
116 Correct 42 ms 23176 KB Output is correct
117 Correct 40 ms 23104 KB Output is correct
118 Correct 45 ms 23712 KB Output is correct
119 Correct 47 ms 23648 KB Output is correct
120 Correct 49 ms 23676 KB Output is correct
121 Correct 46 ms 23696 KB Output is correct
122 Correct 375 ms 73152 KB Output is correct
123 Correct 551 ms 95052 KB Output is correct
124 Correct 524 ms 90024 KB Output is correct
125 Correct 481 ms 83104 KB Output is correct
126 Correct 411 ms 74628 KB Output is correct
127 Correct 260 ms 54296 KB Output is correct
128 Correct 158 ms 39436 KB Output is correct
129 Correct 85 ms 29244 KB Output is correct
130 Correct 27 ms 18772 KB Output is correct
131 Correct 70 ms 30284 KB Output is correct
132 Correct 89 ms 34916 KB Output is correct
133 Correct 97 ms 35044 KB Output is correct
134 Correct 82 ms 34892 KB Output is correct
135 Correct 95 ms 36172 KB Output is correct
136 Correct 100 ms 36244 KB Output is correct
137 Correct 94 ms 36224 KB Output is correct
138 Correct 89 ms 36168 KB Output is correct
139 Correct 97 ms 36044 KB Output is correct
140 Correct 96 ms 36016 KB Output is correct
141 Correct 89 ms 35984 KB Output is correct
142 Correct 1255 ms 196764 KB Output is correct
143 Correct 1227 ms 183072 KB Output is correct
144 Correct 876 ms 135032 KB Output is correct
145 Correct 611 ms 101540 KB Output is correct
146 Correct 266 ms 58500 KB Output is correct
147 Correct 52 ms 24876 KB Output is correct
148 Correct 1238 ms 186524 KB Output is correct
149 Correct 1175 ms 181976 KB Output is correct
150 Correct 1433 ms 206668 KB Output is correct
151 Correct 200 ms 60624 KB Output is correct
152 Correct 213 ms 63620 KB Output is correct
153 Correct 216 ms 62540 KB Output is correct
154 Correct 223 ms 62728 KB Output is correct
155 Correct 223 ms 62564 KB Output is correct
156 Correct 217 ms 62564 KB Output is correct
157 Correct 230 ms 62668 KB Output is correct
158 Correct 219 ms 62636 KB Output is correct
159 Correct 218 ms 62372 KB Output is correct
160 Correct 222 ms 62440 KB Output is correct
161 Correct 192 ms 62388 KB Output is correct
162 Correct 221 ms 60704 KB Output is correct
163 Correct 225 ms 60616 KB Output is correct
164 Correct 218 ms 60696 KB Output is correct
165 Correct 208 ms 60620 KB Output is correct
166 Correct 198 ms 60676 KB Output is correct
167 Correct 189 ms 60612 KB Output is correct