Submission #696764

# Submission time Handle Problem Language Result Execution time Memory
696764 2023-02-07T08:04:20 Z vjudge1 Amusement Park (CEOI19_amusementpark) C++17
100 / 100
2363 ms 3612 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define fir first
#define sec second
typedef vector <int> vi;
typedef vector <ll> vl;
template <typename __Tp> void read(__Tp &x) {
    int f = 0; x = 0; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = 1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    if (f) x = -x;
}
template <typename __Tp1, typename ...__Tp2> void read(__Tp1 &x, __Tp2 &...y) { read(x), read(y...); }
template <typename __Tp> void write(__Tp x) {
    if (x < 0) putchar('-'), x = -x;
    if (x > 9) write(x / 10);
    putchar(x % 10 + 48);
}
void write(char ch) { putchar(ch); }
template <typename __Tp1, typename ...__Tp2> void write(__Tp1 x, __Tp2 ...y) { write(x), write(y...); }

const int mod = 998244353, inv2 = 499122177;
int n, m, e[20], vld[1 << 18], popcnt[1 << 18], lg[1 << 18], f[1 << 18];

int main() {
    read(n, m);
    for (int i = 1; i <= m; ++i) {
        int u, v; read(u, v), --u, --v;
        e[u] |= (1 << v), e[v] |= (1 << u);
    }
    int S = (1 << n) - 1;
    for (int i = 0; i < n; ++i) lg[1 << i] = i;
    vld[0] = 1;
    for (int s = 1; s <= S; ++s) {
        int i = lg[s & -s];
        popcnt[s] = popcnt[s & (s - 1)] + 1;
        vld[s] = vld[s & (s - 1)] & !(e[i] & s);
    }
    f[0] = 1;
    for (int s = 1; s <= S; ++s)
        for (int t = s; t; t = (t - 1) & s)
            if (vld[t]) {
                if (popcnt[t] & 1) f[s] = (f[s] + f[s ^ t]) % mod;
                else f[s] = (f[s] + mod - f[s ^ t]) % mod;
            }
    write((ll) f[S] * m % mod * inv2 % mod, '\n');
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 1 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 1 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 0 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 224 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 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 212 KB Output is correct
18 Correct 0 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 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 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 0 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 1 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 0 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 224 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 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 212 KB Output is correct
18 Correct 0 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 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 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 1 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 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 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 0 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 1 ms 212 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 1 ms 212 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 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 1 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 0 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 224 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 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 212 KB Output is correct
18 Correct 0 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 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 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 1 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 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 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 0 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 1 ms 212 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 1 ms 212 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 212 KB Output is correct
65 Correct 9 ms 468 KB Output is correct
66 Correct 8 ms 524 KB Output is correct
67 Correct 7 ms 484 KB Output is correct
68 Correct 7 ms 524 KB Output is correct
69 Correct 20 ms 484 KB Output is correct
70 Correct 14 ms 520 KB Output is correct
71 Correct 14 ms 500 KB Output is correct
72 Correct 16 ms 496 KB Output is correct
73 Correct 11 ms 492 KB Output is correct
74 Correct 11 ms 492 KB Output is correct
75 Correct 11 ms 468 KB Output is correct
76 Correct 11 ms 520 KB Output is correct
77 Correct 27 ms 672 KB Output is correct
78 Correct 25 ms 676 KB Output is correct
79 Correct 23 ms 656 KB Output is correct
80 Correct 21 ms 680 KB Output is correct
81 Correct 20 ms 632 KB Output is correct
82 Correct 19 ms 708 KB Output is correct
83 Correct 17 ms 652 KB Output is correct
84 Correct 17 ms 660 KB Output is correct
85 Correct 58 ms 680 KB Output is correct
86 Correct 44 ms 688 KB Output is correct
87 Correct 43 ms 692 KB Output is correct
88 Correct 45 ms 664 KB Output is correct
89 Correct 30 ms 676 KB Output is correct
90 Correct 35 ms 696 KB Output is correct
91 Correct 36 ms 716 KB Output is correct
92 Correct 37 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 1 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 0 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 224 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 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 212 KB Output is correct
18 Correct 0 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 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 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 1 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 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 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 0 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 1 ms 212 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 1 ms 212 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 212 KB Output is correct
65 Correct 9 ms 468 KB Output is correct
66 Correct 8 ms 524 KB Output is correct
67 Correct 7 ms 484 KB Output is correct
68 Correct 7 ms 524 KB Output is correct
69 Correct 20 ms 484 KB Output is correct
70 Correct 14 ms 520 KB Output is correct
71 Correct 14 ms 500 KB Output is correct
72 Correct 16 ms 496 KB Output is correct
73 Correct 11 ms 492 KB Output is correct
74 Correct 11 ms 492 KB Output is correct
75 Correct 11 ms 468 KB Output is correct
76 Correct 11 ms 520 KB Output is correct
77 Correct 27 ms 672 KB Output is correct
78 Correct 25 ms 676 KB Output is correct
79 Correct 23 ms 656 KB Output is correct
80 Correct 21 ms 680 KB Output is correct
81 Correct 20 ms 632 KB Output is correct
82 Correct 19 ms 708 KB Output is correct
83 Correct 17 ms 652 KB Output is correct
84 Correct 17 ms 660 KB Output is correct
85 Correct 58 ms 680 KB Output is correct
86 Correct 44 ms 688 KB Output is correct
87 Correct 43 ms 692 KB Output is correct
88 Correct 45 ms 664 KB Output is correct
89 Correct 30 ms 676 KB Output is correct
90 Correct 35 ms 696 KB Output is correct
91 Correct 36 ms 716 KB Output is correct
92 Correct 37 ms 656 KB Output is correct
93 Correct 1103 ms 3516 KB Output is correct
94 Correct 1101 ms 3488 KB Output is correct
95 Correct 1090 ms 3448 KB Output is correct
96 Correct 831 ms 3388 KB Output is correct
97 Correct 694 ms 3440 KB Output is correct
98 Correct 802 ms 3476 KB Output is correct
99 Correct 87 ms 1020 KB Output is correct
100 Correct 75 ms 1032 KB Output is correct
101 Correct 67 ms 1020 KB Output is correct
102 Correct 59 ms 1028 KB Output is correct
103 Correct 778 ms 1852 KB Output is correct
104 Correct 405 ms 1840 KB Output is correct
105 Correct 291 ms 1836 KB Output is correct
106 Correct 212 ms 1784 KB Output is correct
107 Correct 2363 ms 3612 KB Output is correct
108 Correct 842 ms 3472 KB Output is correct
109 Correct 581 ms 3388 KB Output is correct
110 Correct 530 ms 3436 KB Output is correct
111 Correct 54 ms 980 KB Output is correct
112 Correct 51 ms 996 KB Output is correct
113 Correct 52 ms 1100 KB Output is correct
114 Correct 178 ms 1036 KB Output is correct
115 Correct 123 ms 1100 KB Output is correct
116 Correct 129 ms 1076 KB Output is correct
117 Correct 136 ms 1040 KB Output is correct
118 Correct 95 ms 1060 KB Output is correct
119 Correct 113 ms 1072 KB Output is correct
120 Correct 99 ms 1000 KB Output is correct
121 Correct 101 ms 1084 KB Output is correct
122 Correct 183 ms 1760 KB Output is correct
123 Correct 168 ms 1796 KB Output is correct
124 Correct 147 ms 1852 KB Output is correct
125 Correct 143 ms 1752 KB Output is correct
126 Correct 137 ms 1856 KB Output is correct
127 Correct 126 ms 1804 KB Output is correct
128 Correct 122 ms 1824 KB Output is correct
129 Correct 114 ms 1852 KB Output is correct
130 Correct 108 ms 1864 KB Output is correct
131 Correct 521 ms 2032 KB Output is correct
132 Correct 379 ms 1808 KB Output is correct
133 Correct 379 ms 1972 KB Output is correct
134 Correct 397 ms 1824 KB Output is correct
135 Correct 274 ms 1824 KB Output is correct
136 Correct 271 ms 1856 KB Output is correct
137 Correct 292 ms 1800 KB Output is correct
138 Correct 300 ms 1824 KB Output is correct
139 Correct 215 ms 1864 KB Output is correct
140 Correct 228 ms 1864 KB Output is correct
141 Correct 239 ms 1764 KB Output is correct
142 Correct 429 ms 3460 KB Output is correct
143 Correct 405 ms 3388 KB Output is correct
144 Correct 371 ms 3360 KB Output is correct
145 Correct 360 ms 3280 KB Output is correct
146 Correct 327 ms 3436 KB Output is correct
147 Correct 335 ms 3428 KB Output is correct
148 Correct 436 ms 3376 KB Output is correct
149 Correct 423 ms 3392 KB Output is correct
150 Correct 429 ms 3448 KB Output is correct
151 Correct 563 ms 3276 KB Output is correct
152 Correct 572 ms 3452 KB Output is correct
153 Correct 841 ms 3508 KB Output is correct
154 Correct 797 ms 3440 KB Output is correct
155 Correct 863 ms 3448 KB Output is correct
156 Correct 904 ms 3372 KB Output is correct
157 Correct 831 ms 3372 KB Output is correct
158 Correct 875 ms 3392 KB Output is correct
159 Correct 670 ms 3380 KB Output is correct
160 Correct 667 ms 3380 KB Output is correct
161 Correct 710 ms 3400 KB Output is correct
162 Correct 568 ms 3400 KB Output is correct
163 Correct 553 ms 3556 KB Output is correct
164 Correct 526 ms 3456 KB Output is correct
165 Correct 537 ms 3376 KB Output is correct
166 Correct 560 ms 3388 KB Output is correct
167 Correct 567 ms 3356 KB Output is correct