답안 #798304

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798304 2023-07-30T15:07:49 Z Ronin13 Amusement Park (CEOI19_amusementpark) C++17
100 / 100
2673 ms 2708 KB
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <bitset>

#define ll long long 
#define ull unsigned ll
#define f first
#define s second 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back

using namespace std;

const ll mod = 998244353;
ll dp[(1 <<18)];
int main(){
    int n; cin >> n;
    int m; cin >> m;
    bool ind[(1 << n)];
    fill(ind, ind + (1 << n), 1);
    for(int i = 0; i < m; i++){
        int u, v; cin >> u >> v;
        u--, v--;
        ind[(1 << u) | (1 << v)] = false;
    }
    for(int i = 1; i < (1 << n); i++){
        for(int j = 0; j < n; j++){
            if(i & (1 << j)){
                ind[i] &= ind[i ^ (1 << j)];
            }
        }
    }
    dp[0] = 1;
    for(int i = 1; i < (1 << n); i++){
        int j = i;
        while(j){
            if(!ind[j]){
                j = (j - 1) & i;
                continue;
            }
            if(__builtin_popcount(j) & 1)
                dp[i] +=  dp[i ^ j];
            else dp[i] -=  dp[i ^ j];
            dp[i] %= mod; dp[i] += mod; dp[i] %= mod;
            j = (j - 1) & i;
        }
       // cout << dp[i] << "\n";
    }
    cout << (dp[(1 << n) - 1] * m)  % mod * ((mod + 1) / 2) % mod;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 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 304 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 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 304 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 308 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 0 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 308 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 256 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 300 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 308 KB Output is correct
53 Correct 1 ms 308 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 304 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 308 KB Output is correct
63 Correct 1 ms 308 KB Output is correct
64 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 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 304 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 308 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 0 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 308 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 256 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 300 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 308 KB Output is correct
53 Correct 1 ms 308 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 304 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 308 KB Output is correct
63 Correct 1 ms 308 KB Output is correct
64 Correct 1 ms 312 KB Output is correct
65 Correct 9 ms 432 KB Output is correct
66 Correct 9 ms 448 KB Output is correct
67 Correct 8 ms 440 KB Output is correct
68 Correct 8 ms 436 KB Output is correct
69 Correct 23 ms 424 KB Output is correct
70 Correct 16 ms 340 KB Output is correct
71 Correct 17 ms 352 KB Output is correct
72 Correct 18 ms 340 KB Output is correct
73 Correct 12 ms 340 KB Output is correct
74 Correct 12 ms 404 KB Output is correct
75 Correct 13 ms 340 KB Output is correct
76 Correct 15 ms 432 KB Output is correct
77 Correct 29 ms 500 KB Output is correct
78 Correct 25 ms 556 KB Output is correct
79 Correct 23 ms 588 KB Output is correct
80 Correct 22 ms 528 KB Output is correct
81 Correct 20 ms 572 KB Output is correct
82 Correct 19 ms 592 KB Output is correct
83 Correct 18 ms 596 KB Output is correct
84 Correct 18 ms 548 KB Output is correct
85 Correct 67 ms 504 KB Output is correct
86 Correct 47 ms 468 KB Output is correct
87 Correct 49 ms 512 KB Output is correct
88 Correct 52 ms 632 KB Output is correct
89 Correct 33 ms 556 KB Output is correct
90 Correct 36 ms 576 KB Output is correct
91 Correct 37 ms 556 KB Output is correct
92 Correct 39 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 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 304 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 308 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 0 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 308 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 256 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 300 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 308 KB Output is correct
53 Correct 1 ms 308 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 304 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 308 KB Output is correct
63 Correct 1 ms 308 KB Output is correct
64 Correct 1 ms 312 KB Output is correct
65 Correct 9 ms 432 KB Output is correct
66 Correct 9 ms 448 KB Output is correct
67 Correct 8 ms 440 KB Output is correct
68 Correct 8 ms 436 KB Output is correct
69 Correct 23 ms 424 KB Output is correct
70 Correct 16 ms 340 KB Output is correct
71 Correct 17 ms 352 KB Output is correct
72 Correct 18 ms 340 KB Output is correct
73 Correct 12 ms 340 KB Output is correct
74 Correct 12 ms 404 KB Output is correct
75 Correct 13 ms 340 KB Output is correct
76 Correct 15 ms 432 KB Output is correct
77 Correct 29 ms 500 KB Output is correct
78 Correct 25 ms 556 KB Output is correct
79 Correct 23 ms 588 KB Output is correct
80 Correct 22 ms 528 KB Output is correct
81 Correct 20 ms 572 KB Output is correct
82 Correct 19 ms 592 KB Output is correct
83 Correct 18 ms 596 KB Output is correct
84 Correct 18 ms 548 KB Output is correct
85 Correct 67 ms 504 KB Output is correct
86 Correct 47 ms 468 KB Output is correct
87 Correct 49 ms 512 KB Output is correct
88 Correct 52 ms 632 KB Output is correct
89 Correct 33 ms 556 KB Output is correct
90 Correct 36 ms 576 KB Output is correct
91 Correct 37 ms 556 KB Output is correct
92 Correct 39 ms 464 KB Output is correct
93 Correct 1225 ms 2580 KB Output is correct
94 Correct 1247 ms 2552 KB Output is correct
95 Correct 1240 ms 2580 KB Output is correct
96 Correct 912 ms 2540 KB Output is correct
97 Correct 803 ms 2628 KB Output is correct
98 Correct 944 ms 2584 KB Output is correct
99 Correct 89 ms 856 KB Output is correct
100 Correct 83 ms 828 KB Output is correct
101 Correct 74 ms 796 KB Output is correct
102 Correct 59 ms 844 KB Output is correct
103 Correct 888 ms 1432 KB Output is correct
104 Correct 454 ms 1380 KB Output is correct
105 Correct 325 ms 1496 KB Output is correct
106 Correct 220 ms 1412 KB Output is correct
107 Correct 2673 ms 2604 KB Output is correct
108 Correct 892 ms 2568 KB Output is correct
109 Correct 602 ms 2580 KB Output is correct
110 Correct 502 ms 2488 KB Output is correct
111 Correct 62 ms 844 KB Output is correct
112 Correct 54 ms 872 KB Output is correct
113 Correct 49 ms 804 KB Output is correct
114 Correct 199 ms 860 KB Output is correct
115 Correct 136 ms 864 KB Output is correct
116 Correct 151 ms 972 KB Output is correct
117 Correct 155 ms 844 KB Output is correct
118 Correct 98 ms 860 KB Output is correct
119 Correct 103 ms 860 KB Output is correct
120 Correct 110 ms 836 KB Output is correct
121 Correct 120 ms 892 KB Output is correct
122 Correct 181 ms 1324 KB Output is correct
123 Correct 168 ms 1436 KB Output is correct
124 Correct 148 ms 1408 KB Output is correct
125 Correct 167 ms 1412 KB Output is correct
126 Correct 136 ms 1364 KB Output is correct
127 Correct 130 ms 1316 KB Output is correct
128 Correct 120 ms 1424 KB Output is correct
129 Correct 127 ms 1440 KB Output is correct
130 Correct 118 ms 1440 KB Output is correct
131 Correct 604 ms 1520 KB Output is correct
132 Correct 416 ms 1424 KB Output is correct
133 Correct 432 ms 1328 KB Output is correct
134 Correct 459 ms 1432 KB Output is correct
135 Correct 299 ms 1524 KB Output is correct
136 Correct 307 ms 1432 KB Output is correct
137 Correct 327 ms 1356 KB Output is correct
138 Correct 355 ms 1536 KB Output is correct
139 Correct 235 ms 1356 KB Output is correct
140 Correct 258 ms 1432 KB Output is correct
141 Correct 275 ms 1356 KB Output is correct
142 Correct 461 ms 2588 KB Output is correct
143 Correct 408 ms 2560 KB Output is correct
144 Correct 396 ms 2584 KB Output is correct
145 Correct 407 ms 2576 KB Output is correct
146 Correct 360 ms 2580 KB Output is correct
147 Correct 362 ms 2468 KB Output is correct
148 Correct 443 ms 2484 KB Output is correct
149 Correct 445 ms 2576 KB Output is correct
150 Correct 422 ms 2580 KB Output is correct
151 Correct 649 ms 2540 KB Output is correct
152 Correct 639 ms 2548 KB Output is correct
153 Correct 1035 ms 2520 KB Output is correct
154 Correct 897 ms 2496 KB Output is correct
155 Correct 994 ms 2580 KB Output is correct
156 Correct 1034 ms 2648 KB Output is correct
157 Correct 919 ms 2672 KB Output is correct
158 Correct 1018 ms 2584 KB Output is correct
159 Correct 752 ms 2708 KB Output is correct
160 Correct 745 ms 2584 KB Output is correct
161 Correct 818 ms 2512 KB Output is correct
162 Correct 641 ms 2580 KB Output is correct
163 Correct 656 ms 2588 KB Output is correct
164 Correct 604 ms 2476 KB Output is correct
165 Correct 651 ms 2516 KB Output is correct
166 Correct 631 ms 2548 KB Output is correct
167 Correct 660 ms 2476 KB Output is correct