답안 #572962

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572962 2022-06-05T15:03:28 Z piOOE Amusement Park (CEOI19_amusementpark) C++17
100 / 100
1620 ms 234792 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12628 KB Output is correct
2 Correct 7 ms 12628 KB Output is correct
3 Correct 8 ms 12640 KB Output is correct
4 Correct 8 ms 12612 KB Output is correct
5 Correct 7 ms 12628 KB Output is correct
6 Correct 7 ms 12636 KB Output is correct
7 Correct 7 ms 12632 KB Output is correct
8 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 8 ms 12640 KB Output is correct
4 Correct 8 ms 12612 KB Output is correct
5 Correct 7 ms 12628 KB Output is correct
6 Correct 7 ms 12636 KB Output is correct
7 Correct 7 ms 12632 KB Output is correct
8 Correct 8 ms 12628 KB Output is correct
9 Correct 6 ms 12628 KB Output is correct
10 Correct 7 ms 12564 KB Output is correct
11 Correct 8 ms 12636 KB Output is correct
12 Correct 6 ms 12640 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 7 ms 12640 KB Output is correct
15 Correct 7 ms 12632 KB Output is correct
16 Correct 7 ms 12520 KB Output is correct
17 Correct 7 ms 12628 KB Output is correct
18 Correct 7 ms 12628 KB Output is correct
19 Correct 8 ms 12648 KB Output is correct
20 Correct 6 ms 12628 KB Output is correct
21 Correct 7 ms 12632 KB Output is correct
22 Correct 7 ms 12632 KB Output is correct
23 Correct 6 ms 12628 KB Output is correct
24 Correct 7 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 8 ms 12640 KB Output is correct
4 Correct 8 ms 12612 KB Output is correct
5 Correct 7 ms 12628 KB Output is correct
6 Correct 7 ms 12636 KB Output is correct
7 Correct 7 ms 12632 KB Output is correct
8 Correct 8 ms 12628 KB Output is correct
9 Correct 6 ms 12628 KB Output is correct
10 Correct 7 ms 12564 KB Output is correct
11 Correct 8 ms 12636 KB Output is correct
12 Correct 6 ms 12640 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 7 ms 12640 KB Output is correct
15 Correct 7 ms 12632 KB Output is correct
16 Correct 7 ms 12520 KB Output is correct
17 Correct 7 ms 12628 KB Output is correct
18 Correct 7 ms 12628 KB Output is correct
19 Correct 8 ms 12648 KB Output is correct
20 Correct 6 ms 12628 KB Output is correct
21 Correct 7 ms 12632 KB Output is correct
22 Correct 7 ms 12632 KB Output is correct
23 Correct 6 ms 12628 KB Output is correct
24 Correct 7 ms 12628 KB Output is correct
25 Correct 6 ms 12632 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 6 ms 12628 KB Output is correct
28 Correct 7 ms 12640 KB Output is correct
29 Correct 6 ms 12632 KB Output is correct
30 Correct 8 ms 12628 KB Output is correct
31 Correct 7 ms 12628 KB Output is correct
32 Correct 6 ms 12628 KB Output is correct
33 Correct 8 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 6 ms 12628 KB Output is correct
37 Correct 7 ms 12640 KB Output is correct
38 Correct 6 ms 12628 KB Output is correct
39 Correct 6 ms 12640 KB Output is correct
40 Correct 7 ms 12628 KB Output is correct
41 Correct 6 ms 12628 KB Output is correct
42 Correct 7 ms 12628 KB Output is correct
43 Correct 7 ms 12628 KB Output is correct
44 Correct 7 ms 12596 KB Output is correct
45 Correct 6 ms 12648 KB Output is correct
46 Correct 6 ms 12628 KB Output is correct
47 Correct 7 ms 12636 KB Output is correct
48 Correct 7 ms 12628 KB Output is correct
49 Correct 6 ms 12644 KB Output is correct
50 Correct 7 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 12640 KB Output is correct
54 Correct 7 ms 12768 KB Output is correct
55 Correct 7 ms 12672 KB Output is correct
56 Correct 8 ms 12772 KB Output is correct
57 Correct 7 ms 12756 KB Output is correct
58 Correct 7 ms 12756 KB Output is correct
59 Correct 7 ms 12640 KB Output is correct
60 Correct 7 ms 12640 KB Output is correct
61 Correct 7 ms 12628 KB Output is correct
62 Correct 7 ms 12628 KB Output is correct
63 Correct 8 ms 12644 KB Output is correct
64 Correct 7 ms 12644 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 8 ms 12640 KB Output is correct
4 Correct 8 ms 12612 KB Output is correct
5 Correct 7 ms 12628 KB Output is correct
6 Correct 7 ms 12636 KB Output is correct
7 Correct 7 ms 12632 KB Output is correct
8 Correct 8 ms 12628 KB Output is correct
9 Correct 6 ms 12628 KB Output is correct
10 Correct 7 ms 12564 KB Output is correct
11 Correct 8 ms 12636 KB Output is correct
12 Correct 6 ms 12640 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 7 ms 12640 KB Output is correct
15 Correct 7 ms 12632 KB Output is correct
16 Correct 7 ms 12520 KB Output is correct
17 Correct 7 ms 12628 KB Output is correct
18 Correct 7 ms 12628 KB Output is correct
19 Correct 8 ms 12648 KB Output is correct
20 Correct 6 ms 12628 KB Output is correct
21 Correct 7 ms 12632 KB Output is correct
22 Correct 7 ms 12632 KB Output is correct
23 Correct 6 ms 12628 KB Output is correct
24 Correct 7 ms 12628 KB Output is correct
25 Correct 6 ms 12632 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 6 ms 12628 KB Output is correct
28 Correct 7 ms 12640 KB Output is correct
29 Correct 6 ms 12632 KB Output is correct
30 Correct 8 ms 12628 KB Output is correct
31 Correct 7 ms 12628 KB Output is correct
32 Correct 6 ms 12628 KB Output is correct
33 Correct 8 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 6 ms 12628 KB Output is correct
37 Correct 7 ms 12640 KB Output is correct
38 Correct 6 ms 12628 KB Output is correct
39 Correct 6 ms 12640 KB Output is correct
40 Correct 7 ms 12628 KB Output is correct
41 Correct 6 ms 12628 KB Output is correct
42 Correct 7 ms 12628 KB Output is correct
43 Correct 7 ms 12628 KB Output is correct
44 Correct 7 ms 12596 KB Output is correct
45 Correct 6 ms 12648 KB Output is correct
46 Correct 6 ms 12628 KB Output is correct
47 Correct 7 ms 12636 KB Output is correct
48 Correct 7 ms 12628 KB Output is correct
49 Correct 6 ms 12644 KB Output is correct
50 Correct 7 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 12640 KB Output is correct
54 Correct 7 ms 12768 KB Output is correct
55 Correct 7 ms 12672 KB Output is correct
56 Correct 8 ms 12772 KB Output is correct
57 Correct 7 ms 12756 KB Output is correct
58 Correct 7 ms 12756 KB Output is correct
59 Correct 7 ms 12640 KB Output is correct
60 Correct 7 ms 12640 KB Output is correct
61 Correct 7 ms 12628 KB Output is correct
62 Correct 7 ms 12628 KB Output is correct
63 Correct 8 ms 12644 KB Output is correct
64 Correct 7 ms 12644 KB Output is correct
65 Correct 29 ms 17312 KB Output is correct
66 Correct 37 ms 18764 KB Output is correct
67 Correct 34 ms 18260 KB Output is correct
68 Correct 33 ms 17880 KB Output is correct
69 Correct 13 ms 14568 KB Output is correct
70 Correct 13 ms 14932 KB Output is correct
71 Correct 18 ms 14932 KB Output is correct
72 Correct 13 ms 14996 KB Output is correct
73 Correct 14 ms 15072 KB Output is correct
74 Correct 14 ms 15060 KB Output is correct
75 Correct 14 ms 15060 KB Output is correct
76 Correct 13 ms 15060 KB Output is correct
77 Correct 61 ms 23860 KB Output is correct
78 Correct 69 ms 25036 KB Output is correct
79 Correct 91 ms 28080 KB Output is correct
80 Correct 74 ms 25436 KB Output is correct
81 Correct 87 ms 26704 KB Output is correct
82 Correct 74 ms 25320 KB Output is correct
83 Correct 75 ms 24792 KB Output is correct
84 Correct 50 ms 21324 KB Output is correct
85 Correct 17 ms 16660 KB Output is correct
86 Correct 23 ms 17520 KB Output is correct
87 Correct 23 ms 17632 KB Output is correct
88 Correct 21 ms 17620 KB Output is correct
89 Correct 23 ms 17740 KB Output is correct
90 Correct 23 ms 17736 KB Output is correct
91 Correct 24 ms 17764 KB Output is correct
92 Correct 22 ms 17776 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 8 ms 12640 KB Output is correct
4 Correct 8 ms 12612 KB Output is correct
5 Correct 7 ms 12628 KB Output is correct
6 Correct 7 ms 12636 KB Output is correct
7 Correct 7 ms 12632 KB Output is correct
8 Correct 8 ms 12628 KB Output is correct
9 Correct 6 ms 12628 KB Output is correct
10 Correct 7 ms 12564 KB Output is correct
11 Correct 8 ms 12636 KB Output is correct
12 Correct 6 ms 12640 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 7 ms 12640 KB Output is correct
15 Correct 7 ms 12632 KB Output is correct
16 Correct 7 ms 12520 KB Output is correct
17 Correct 7 ms 12628 KB Output is correct
18 Correct 7 ms 12628 KB Output is correct
19 Correct 8 ms 12648 KB Output is correct
20 Correct 6 ms 12628 KB Output is correct
21 Correct 7 ms 12632 KB Output is correct
22 Correct 7 ms 12632 KB Output is correct
23 Correct 6 ms 12628 KB Output is correct
24 Correct 7 ms 12628 KB Output is correct
25 Correct 6 ms 12632 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 6 ms 12628 KB Output is correct
28 Correct 7 ms 12640 KB Output is correct
29 Correct 6 ms 12632 KB Output is correct
30 Correct 8 ms 12628 KB Output is correct
31 Correct 7 ms 12628 KB Output is correct
32 Correct 6 ms 12628 KB Output is correct
33 Correct 8 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 6 ms 12628 KB Output is correct
37 Correct 7 ms 12640 KB Output is correct
38 Correct 6 ms 12628 KB Output is correct
39 Correct 6 ms 12640 KB Output is correct
40 Correct 7 ms 12628 KB Output is correct
41 Correct 6 ms 12628 KB Output is correct
42 Correct 7 ms 12628 KB Output is correct
43 Correct 7 ms 12628 KB Output is correct
44 Correct 7 ms 12596 KB Output is correct
45 Correct 6 ms 12648 KB Output is correct
46 Correct 6 ms 12628 KB Output is correct
47 Correct 7 ms 12636 KB Output is correct
48 Correct 7 ms 12628 KB Output is correct
49 Correct 6 ms 12644 KB Output is correct
50 Correct 7 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 12640 KB Output is correct
54 Correct 7 ms 12768 KB Output is correct
55 Correct 7 ms 12672 KB Output is correct
56 Correct 8 ms 12772 KB Output is correct
57 Correct 7 ms 12756 KB Output is correct
58 Correct 7 ms 12756 KB Output is correct
59 Correct 7 ms 12640 KB Output is correct
60 Correct 7 ms 12640 KB Output is correct
61 Correct 7 ms 12628 KB Output is correct
62 Correct 7 ms 12628 KB Output is correct
63 Correct 8 ms 12644 KB Output is correct
64 Correct 7 ms 12644 KB Output is correct
65 Correct 29 ms 17312 KB Output is correct
66 Correct 37 ms 18764 KB Output is correct
67 Correct 34 ms 18260 KB Output is correct
68 Correct 33 ms 17880 KB Output is correct
69 Correct 13 ms 14568 KB Output is correct
70 Correct 13 ms 14932 KB Output is correct
71 Correct 18 ms 14932 KB Output is correct
72 Correct 13 ms 14996 KB Output is correct
73 Correct 14 ms 15072 KB Output is correct
74 Correct 14 ms 15060 KB Output is correct
75 Correct 14 ms 15060 KB Output is correct
76 Correct 13 ms 15060 KB Output is correct
77 Correct 61 ms 23860 KB Output is correct
78 Correct 69 ms 25036 KB Output is correct
79 Correct 91 ms 28080 KB Output is correct
80 Correct 74 ms 25436 KB Output is correct
81 Correct 87 ms 26704 KB Output is correct
82 Correct 74 ms 25320 KB Output is correct
83 Correct 75 ms 24792 KB Output is correct
84 Correct 50 ms 21324 KB Output is correct
85 Correct 17 ms 16660 KB Output is correct
86 Correct 23 ms 17520 KB Output is correct
87 Correct 23 ms 17632 KB Output is correct
88 Correct 21 ms 17620 KB Output is correct
89 Correct 23 ms 17740 KB Output is correct
90 Correct 23 ms 17736 KB Output is correct
91 Correct 24 ms 17764 KB Output is correct
92 Correct 22 ms 17776 KB Output is correct
93 Correct 208 ms 59648 KB Output is correct
94 Correct 78 ms 32332 KB Output is correct
95 Correct 40 ms 26496 KB Output is correct
96 Correct 211 ms 62628 KB Output is correct
97 Correct 218 ms 62028 KB Output is correct
98 Correct 190 ms 58656 KB Output is correct
99 Correct 79 ms 29400 KB Output is correct
100 Correct 149 ms 38892 KB Output is correct
101 Correct 232 ms 46872 KB Output is correct
102 Correct 293 ms 48716 KB Output is correct
103 Correct 24 ms 18720 KB Output is correct
104 Correct 22 ms 19284 KB Output is correct
105 Correct 78 ms 30968 KB Output is correct
106 Correct 310 ms 66440 KB Output is correct
107 Correct 30 ms 24916 KB Output is correct
108 Correct 173 ms 54512 KB Output is correct
109 Correct 725 ms 131068 KB Output is correct
110 Correct 1620 ms 234792 KB Output is correct
111 Correct 220 ms 48456 KB Output is correct
112 Correct 179 ms 41816 KB Output is correct
113 Correct 168 ms 40064 KB Output is correct
114 Correct 32 ms 21076 KB Output is correct
115 Correct 42 ms 23112 KB Output is correct
116 Correct 41 ms 23116 KB Output is correct
117 Correct 39 ms 23120 KB Output is correct
118 Correct 46 ms 23776 KB Output is correct
119 Correct 53 ms 23692 KB Output is correct
120 Correct 43 ms 23700 KB Output is correct
121 Correct 41 ms 23664 KB Output is correct
122 Correct 360 ms 73252 KB Output is correct
123 Correct 535 ms 95164 KB Output is correct
124 Correct 507 ms 90032 KB Output is correct
125 Correct 463 ms 83108 KB Output is correct
126 Correct 419 ms 74796 KB Output is correct
127 Correct 265 ms 54392 KB Output is correct
128 Correct 151 ms 39496 KB Output is correct
129 Correct 90 ms 29132 KB Output is correct
130 Correct 28 ms 18800 KB Output is correct
131 Correct 66 ms 30296 KB Output is correct
132 Correct 86 ms 34888 KB Output is correct
133 Correct 88 ms 34892 KB Output is correct
134 Correct 90 ms 34904 KB Output is correct
135 Correct 98 ms 36428 KB Output is correct
136 Correct 98 ms 36284 KB Output is correct
137 Correct 92 ms 36268 KB Output is correct
138 Correct 87 ms 36264 KB Output is correct
139 Correct 101 ms 36084 KB Output is correct
140 Correct 109 ms 36172 KB Output is correct
141 Correct 124 ms 36036 KB Output is correct
142 Correct 1245 ms 196672 KB Output is correct
143 Correct 1233 ms 182736 KB Output is correct
144 Correct 850 ms 135020 KB Output is correct
145 Correct 603 ms 101428 KB Output is correct
146 Correct 272 ms 58572 KB Output is correct
147 Correct 51 ms 24828 KB Output is correct
148 Correct 1212 ms 186412 KB Output is correct
149 Correct 1177 ms 181992 KB Output is correct
150 Correct 1425 ms 206844 KB Output is correct
151 Correct 191 ms 60492 KB Output is correct
152 Correct 220 ms 63700 KB Output is correct
153 Correct 206 ms 62636 KB Output is correct
154 Correct 214 ms 62628 KB Output is correct
155 Correct 229 ms 62696 KB Output is correct
156 Correct 192 ms 62636 KB Output is correct
157 Correct 221 ms 62564 KB Output is correct
158 Correct 229 ms 62704 KB Output is correct
159 Correct 214 ms 62448 KB Output is correct
160 Correct 217 ms 62432 KB Output is correct
161 Correct 202 ms 62396 KB Output is correct
162 Correct 209 ms 60704 KB Output is correct
163 Correct 220 ms 60712 KB Output is correct
164 Correct 229 ms 60696 KB Output is correct
165 Correct 231 ms 60620 KB Output is correct
166 Correct 193 ms 60640 KB Output is correct
167 Correct 193 ms 60656 KB Output is correct