답안 #572964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572964 2022-06-05T15:05:52 Z piOOE Amusement Park (CEOI19_amusementpark) C++17
100 / 100
1562 ms 234760 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));
      |                                    ~~~~~~~~~^~~~~~~~~~~~~~~~
amusementpark.cpp:47:48: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
   47 |                     newb = newb | (adj[i] | a) ^ a;
      |                                   ~~~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12628 KB Output is correct
2 Correct 7 ms 12628 KB Output is correct
3 Correct 6 ms 12628 KB Output is correct
4 Correct 6 ms 12628 KB Output is correct
5 Correct 6 ms 12628 KB Output is correct
6 Correct 6 ms 12628 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 6 ms 12572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12628 KB Output is correct
2 Correct 7 ms 12628 KB Output is correct
3 Correct 6 ms 12628 KB Output is correct
4 Correct 6 ms 12628 KB Output is correct
5 Correct 6 ms 12628 KB Output is correct
6 Correct 6 ms 12628 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 6 ms 12572 KB Output is correct
9 Correct 6 ms 12564 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 6 ms 12628 KB Output is correct
13 Correct 6 ms 12628 KB Output is correct
14 Correct 6 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 8 ms 12628 KB Output is correct
18 Correct 6 ms 12636 KB Output is correct
19 Correct 7 ms 12500 KB Output is correct
20 Correct 6 ms 12628 KB Output is correct
21 Correct 7 ms 12628 KB Output is correct
22 Correct 6 ms 12628 KB Output is correct
23 Correct 6 ms 12628 KB Output is correct
24 Correct 6 ms 12628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12628 KB Output is correct
2 Correct 7 ms 12628 KB Output is correct
3 Correct 6 ms 12628 KB Output is correct
4 Correct 6 ms 12628 KB Output is correct
5 Correct 6 ms 12628 KB Output is correct
6 Correct 6 ms 12628 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 6 ms 12572 KB Output is correct
9 Correct 6 ms 12564 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 6 ms 12628 KB Output is correct
13 Correct 6 ms 12628 KB Output is correct
14 Correct 6 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 8 ms 12628 KB Output is correct
18 Correct 6 ms 12636 KB Output is correct
19 Correct 7 ms 12500 KB Output is correct
20 Correct 6 ms 12628 KB Output is correct
21 Correct 7 ms 12628 KB Output is correct
22 Correct 6 ms 12628 KB Output is correct
23 Correct 6 ms 12628 KB Output is correct
24 Correct 6 ms 12628 KB Output is correct
25 Correct 6 ms 12628 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 6 ms 12612 KB Output is correct
28 Correct 6 ms 12628 KB Output is correct
29 Correct 7 ms 12628 KB Output is correct
30 Correct 7 ms 12640 KB Output is correct
31 Correct 7 ms 12644 KB Output is correct
32 Correct 6 ms 12628 KB Output is correct
33 Correct 8 ms 12628 KB Output is correct
34 Correct 7 ms 12628 KB Output is correct
35 Correct 7 ms 12648 KB Output is correct
36 Correct 7 ms 12636 KB Output is correct
37 Correct 6 ms 12628 KB Output is correct
38 Correct 6 ms 12628 KB Output is correct
39 Correct 6 ms 12628 KB Output is correct
40 Correct 7 ms 12604 KB Output is correct
41 Correct 6 ms 12628 KB Output is correct
42 Correct 6 ms 12628 KB Output is correct
43 Correct 7 ms 12628 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 7 ms 12628 KB Output is correct
46 Correct 6 ms 12628 KB Output is correct
47 Correct 6 ms 12628 KB Output is correct
48 Correct 6 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 7 ms 12560 KB Output is correct
52 Correct 6 ms 12652 KB Output is correct
53 Correct 7 ms 12668 KB Output is correct
54 Correct 7 ms 12756 KB Output is correct
55 Correct 7 ms 12628 KB Output is correct
56 Correct 7 ms 12716 KB Output is correct
57 Correct 7 ms 12756 KB Output is correct
58 Correct 7 ms 12732 KB Output is correct
59 Correct 7 ms 12628 KB Output is correct
60 Correct 6 ms 12628 KB Output is correct
61 Correct 6 ms 12628 KB Output is correct
62 Correct 6 ms 12628 KB Output is correct
63 Correct 6 ms 12628 KB Output is correct
64 Correct 8 ms 12628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12628 KB Output is correct
2 Correct 7 ms 12628 KB Output is correct
3 Correct 6 ms 12628 KB Output is correct
4 Correct 6 ms 12628 KB Output is correct
5 Correct 6 ms 12628 KB Output is correct
6 Correct 6 ms 12628 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 6 ms 12572 KB Output is correct
9 Correct 6 ms 12564 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 6 ms 12628 KB Output is correct
13 Correct 6 ms 12628 KB Output is correct
14 Correct 6 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 8 ms 12628 KB Output is correct
18 Correct 6 ms 12636 KB Output is correct
19 Correct 7 ms 12500 KB Output is correct
20 Correct 6 ms 12628 KB Output is correct
21 Correct 7 ms 12628 KB Output is correct
22 Correct 6 ms 12628 KB Output is correct
23 Correct 6 ms 12628 KB Output is correct
24 Correct 6 ms 12628 KB Output is correct
25 Correct 6 ms 12628 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 6 ms 12612 KB Output is correct
28 Correct 6 ms 12628 KB Output is correct
29 Correct 7 ms 12628 KB Output is correct
30 Correct 7 ms 12640 KB Output is correct
31 Correct 7 ms 12644 KB Output is correct
32 Correct 6 ms 12628 KB Output is correct
33 Correct 8 ms 12628 KB Output is correct
34 Correct 7 ms 12628 KB Output is correct
35 Correct 7 ms 12648 KB Output is correct
36 Correct 7 ms 12636 KB Output is correct
37 Correct 6 ms 12628 KB Output is correct
38 Correct 6 ms 12628 KB Output is correct
39 Correct 6 ms 12628 KB Output is correct
40 Correct 7 ms 12604 KB Output is correct
41 Correct 6 ms 12628 KB Output is correct
42 Correct 6 ms 12628 KB Output is correct
43 Correct 7 ms 12628 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 7 ms 12628 KB Output is correct
46 Correct 6 ms 12628 KB Output is correct
47 Correct 6 ms 12628 KB Output is correct
48 Correct 6 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 7 ms 12560 KB Output is correct
52 Correct 6 ms 12652 KB Output is correct
53 Correct 7 ms 12668 KB Output is correct
54 Correct 7 ms 12756 KB Output is correct
55 Correct 7 ms 12628 KB Output is correct
56 Correct 7 ms 12716 KB Output is correct
57 Correct 7 ms 12756 KB Output is correct
58 Correct 7 ms 12732 KB Output is correct
59 Correct 7 ms 12628 KB Output is correct
60 Correct 6 ms 12628 KB Output is correct
61 Correct 6 ms 12628 KB Output is correct
62 Correct 6 ms 12628 KB Output is correct
63 Correct 6 ms 12628 KB Output is correct
64 Correct 8 ms 12628 KB Output is correct
65 Correct 26 ms 17224 KB Output is correct
66 Correct 37 ms 18780 KB Output is correct
67 Correct 34 ms 18260 KB Output is correct
68 Correct 33 ms 17944 KB Output is correct
69 Correct 12 ms 14548 KB Output is correct
70 Correct 13 ms 14944 KB Output is correct
71 Correct 13 ms 14932 KB Output is correct
72 Correct 13 ms 14932 KB Output is correct
73 Correct 13 ms 15060 KB Output is correct
74 Correct 17 ms 15060 KB Output is correct
75 Correct 16 ms 15060 KB Output is correct
76 Correct 13 ms 15052 KB Output is correct
77 Correct 63 ms 23792 KB Output is correct
78 Correct 64 ms 25028 KB Output is correct
79 Correct 93 ms 28108 KB Output is correct
80 Correct 93 ms 25456 KB Output is correct
81 Correct 91 ms 26772 KB Output is correct
82 Correct 92 ms 25276 KB Output is correct
83 Correct 77 ms 24780 KB Output is correct
84 Correct 52 ms 21316 KB Output is correct
85 Correct 20 ms 16564 KB Output is correct
86 Correct 22 ms 17620 KB Output is correct
87 Correct 22 ms 17632 KB Output is correct
88 Correct 24 ms 17620 KB Output is correct
89 Correct 24 ms 17844 KB Output is correct
90 Correct 23 ms 17764 KB Output is correct
91 Correct 25 ms 17876 KB Output is correct
92 Correct 35 ms 17804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12628 KB Output is correct
2 Correct 7 ms 12628 KB Output is correct
3 Correct 6 ms 12628 KB Output is correct
4 Correct 6 ms 12628 KB Output is correct
5 Correct 6 ms 12628 KB Output is correct
6 Correct 6 ms 12628 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 6 ms 12572 KB Output is correct
9 Correct 6 ms 12564 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 6 ms 12628 KB Output is correct
12 Correct 6 ms 12628 KB Output is correct
13 Correct 6 ms 12628 KB Output is correct
14 Correct 6 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 8 ms 12628 KB Output is correct
18 Correct 6 ms 12636 KB Output is correct
19 Correct 7 ms 12500 KB Output is correct
20 Correct 6 ms 12628 KB Output is correct
21 Correct 7 ms 12628 KB Output is correct
22 Correct 6 ms 12628 KB Output is correct
23 Correct 6 ms 12628 KB Output is correct
24 Correct 6 ms 12628 KB Output is correct
25 Correct 6 ms 12628 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 6 ms 12612 KB Output is correct
28 Correct 6 ms 12628 KB Output is correct
29 Correct 7 ms 12628 KB Output is correct
30 Correct 7 ms 12640 KB Output is correct
31 Correct 7 ms 12644 KB Output is correct
32 Correct 6 ms 12628 KB Output is correct
33 Correct 8 ms 12628 KB Output is correct
34 Correct 7 ms 12628 KB Output is correct
35 Correct 7 ms 12648 KB Output is correct
36 Correct 7 ms 12636 KB Output is correct
37 Correct 6 ms 12628 KB Output is correct
38 Correct 6 ms 12628 KB Output is correct
39 Correct 6 ms 12628 KB Output is correct
40 Correct 7 ms 12604 KB Output is correct
41 Correct 6 ms 12628 KB Output is correct
42 Correct 6 ms 12628 KB Output is correct
43 Correct 7 ms 12628 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 7 ms 12628 KB Output is correct
46 Correct 6 ms 12628 KB Output is correct
47 Correct 6 ms 12628 KB Output is correct
48 Correct 6 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 7 ms 12560 KB Output is correct
52 Correct 6 ms 12652 KB Output is correct
53 Correct 7 ms 12668 KB Output is correct
54 Correct 7 ms 12756 KB Output is correct
55 Correct 7 ms 12628 KB Output is correct
56 Correct 7 ms 12716 KB Output is correct
57 Correct 7 ms 12756 KB Output is correct
58 Correct 7 ms 12732 KB Output is correct
59 Correct 7 ms 12628 KB Output is correct
60 Correct 6 ms 12628 KB Output is correct
61 Correct 6 ms 12628 KB Output is correct
62 Correct 6 ms 12628 KB Output is correct
63 Correct 6 ms 12628 KB Output is correct
64 Correct 8 ms 12628 KB Output is correct
65 Correct 26 ms 17224 KB Output is correct
66 Correct 37 ms 18780 KB Output is correct
67 Correct 34 ms 18260 KB Output is correct
68 Correct 33 ms 17944 KB Output is correct
69 Correct 12 ms 14548 KB Output is correct
70 Correct 13 ms 14944 KB Output is correct
71 Correct 13 ms 14932 KB Output is correct
72 Correct 13 ms 14932 KB Output is correct
73 Correct 13 ms 15060 KB Output is correct
74 Correct 17 ms 15060 KB Output is correct
75 Correct 16 ms 15060 KB Output is correct
76 Correct 13 ms 15052 KB Output is correct
77 Correct 63 ms 23792 KB Output is correct
78 Correct 64 ms 25028 KB Output is correct
79 Correct 93 ms 28108 KB Output is correct
80 Correct 93 ms 25456 KB Output is correct
81 Correct 91 ms 26772 KB Output is correct
82 Correct 92 ms 25276 KB Output is correct
83 Correct 77 ms 24780 KB Output is correct
84 Correct 52 ms 21316 KB Output is correct
85 Correct 20 ms 16564 KB Output is correct
86 Correct 22 ms 17620 KB Output is correct
87 Correct 22 ms 17632 KB Output is correct
88 Correct 24 ms 17620 KB Output is correct
89 Correct 24 ms 17844 KB Output is correct
90 Correct 23 ms 17764 KB Output is correct
91 Correct 25 ms 17876 KB Output is correct
92 Correct 35 ms 17804 KB Output is correct
93 Correct 213 ms 59508 KB Output is correct
94 Correct 77 ms 32320 KB Output is correct
95 Correct 50 ms 26508 KB Output is correct
96 Correct 241 ms 62532 KB Output is correct
97 Correct 237 ms 61868 KB Output is correct
98 Correct 218 ms 58680 KB Output is correct
99 Correct 87 ms 29416 KB Output is correct
100 Correct 154 ms 38792 KB Output is correct
101 Correct 229 ms 46828 KB Output is correct
102 Correct 340 ms 48732 KB Output is correct
103 Correct 27 ms 18684 KB Output is correct
104 Correct 28 ms 19204 KB Output is correct
105 Correct 64 ms 30756 KB Output is correct
106 Correct 352 ms 66536 KB Output is correct
107 Correct 31 ms 24908 KB Output is correct
108 Correct 133 ms 54604 KB Output is correct
109 Correct 678 ms 131144 KB Output is correct
110 Correct 1562 ms 234760 KB Output is correct
111 Correct 234 ms 48504 KB Output is correct
112 Correct 176 ms 41644 KB Output is correct
113 Correct 168 ms 40060 KB Output is correct
114 Correct 31 ms 21068 KB Output is correct
115 Correct 42 ms 23152 KB Output is correct
116 Correct 41 ms 23076 KB Output is correct
117 Correct 40 ms 23132 KB Output is correct
118 Correct 44 ms 23656 KB Output is correct
119 Correct 45 ms 23760 KB Output is correct
120 Correct 44 ms 23768 KB Output is correct
121 Correct 42 ms 23704 KB Output is correct
122 Correct 381 ms 73252 KB Output is correct
123 Correct 536 ms 94996 KB Output is correct
124 Correct 520 ms 89916 KB Output is correct
125 Correct 473 ms 83044 KB Output is correct
126 Correct 430 ms 74792 KB Output is correct
127 Correct 266 ms 54412 KB Output is correct
128 Correct 159 ms 39644 KB Output is correct
129 Correct 84 ms 29212 KB Output is correct
130 Correct 27 ms 18772 KB Output is correct
131 Correct 68 ms 30292 KB Output is correct
132 Correct 87 ms 34816 KB Output is correct
133 Correct 99 ms 34924 KB Output is correct
134 Correct 103 ms 34936 KB Output is correct
135 Correct 103 ms 36180 KB Output is correct
136 Correct 102 ms 36240 KB Output is correct
137 Correct 98 ms 36268 KB Output is correct
138 Correct 91 ms 36172 KB Output is correct
139 Correct 105 ms 36256 KB Output is correct
140 Correct 97 ms 36088 KB Output is correct
141 Correct 93 ms 36044 KB Output is correct
142 Correct 1361 ms 196756 KB Output is correct
143 Correct 1327 ms 182796 KB Output is correct
144 Correct 925 ms 135080 KB Output is correct
145 Correct 788 ms 101384 KB Output is correct
146 Correct 302 ms 58404 KB Output is correct
147 Correct 53 ms 24924 KB Output is correct
148 Correct 1249 ms 186560 KB Output is correct
149 Correct 1182 ms 181996 KB Output is correct
150 Correct 1466 ms 206796 KB Output is correct
151 Correct 222 ms 60456 KB Output is correct
152 Correct 218 ms 63552 KB Output is correct
153 Correct 223 ms 62628 KB Output is correct
154 Correct 221 ms 62572 KB Output is correct
155 Correct 230 ms 62612 KB Output is correct
156 Correct 202 ms 62632 KB Output is correct
157 Correct 225 ms 62512 KB Output is correct
158 Correct 218 ms 62532 KB Output is correct
159 Correct 231 ms 62472 KB Output is correct
160 Correct 222 ms 62412 KB Output is correct
161 Correct 207 ms 62400 KB Output is correct
162 Correct 247 ms 60680 KB Output is correct
163 Correct 249 ms 60620 KB Output is correct
164 Correct 231 ms 60664 KB Output is correct
165 Correct 220 ms 60764 KB Output is correct
166 Correct 204 ms 60704 KB Output is correct
167 Correct 185 ms 60704 KB Output is correct