Submission #348744

# Submission time Handle Problem Language Result Execution time Memory
348744 2021-01-15T15:57:00 Z doowey Amusement Park (CEOI19_amusementpark) C++14
100 / 100
1812 ms 234988 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 18;
const int MOD = 998244353;
int mask[N];
map<int,int> dp[1<<N];

void add(int &a, int b){
    a += b;
    a %= MOD;
}

int main(){
    fastIO;
    int n,m;
    cin >> n >> m;
    int u, v;
    for(int i = 1; i <= m; i ++ ){
        cin >> u >> v;
        u--;
        v--;
        mask[u] |= (1 << v);
        mask[v] |= (1 << u);
    }
    dp[0][(1<<n)-1]=1;
    int cur, msk;
    int val;
    int nah;
    for(int i = 0 ; i < (1 << n); i ++ ){
        for(auto x : dp[i]){
            cur = i;
            msk = x.fi;
            val = x.se;
            for(int nx = 0 ; nx < n; nx ++ ){
                if((msk & (1 << nx))){
                    nah = (msk & (((1<<n)-1)-((1<<(nx+1))-1)));
                    nah = (nah | ((mask[nx]|i)^i));
                    add(dp[(i|(1<<nx))][nah],val);
                }
            }
        }
    }
    int sol = dp[(1<<n)-1][0];
    sol = (sol * 1ll * m) % MOD;
    sol = (sol * 1ll * (MOD+1)/2) % MOD;
    cout << sol << "\n";
    return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:36:9: warning: variable 'cur' set but not used [-Wunused-but-set-variable]
   36 |     int cur, msk;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 12652 KB Output is correct
2 Correct 9 ms 12652 KB Output is correct
3 Correct 9 ms 12652 KB Output is correct
4 Correct 9 ms 12652 KB Output is correct
5 Correct 9 ms 12652 KB Output is correct
6 Correct 9 ms 12652 KB Output is correct
7 Correct 9 ms 12652 KB Output is correct
8 Correct 9 ms 12652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 12652 KB Output is correct
2 Correct 9 ms 12652 KB Output is correct
3 Correct 9 ms 12652 KB Output is correct
4 Correct 9 ms 12652 KB Output is correct
5 Correct 9 ms 12652 KB Output is correct
6 Correct 9 ms 12652 KB Output is correct
7 Correct 9 ms 12652 KB Output is correct
8 Correct 9 ms 12652 KB Output is correct
9 Correct 11 ms 12652 KB Output is correct
10 Correct 9 ms 12652 KB Output is correct
11 Correct 10 ms 12652 KB Output is correct
12 Correct 9 ms 12652 KB Output is correct
13 Correct 9 ms 12652 KB Output is correct
14 Correct 9 ms 12652 KB Output is correct
15 Correct 9 ms 12652 KB Output is correct
16 Correct 9 ms 12652 KB Output is correct
17 Correct 9 ms 12652 KB Output is correct
18 Correct 9 ms 12780 KB Output is correct
19 Correct 11 ms 12604 KB Output is correct
20 Correct 9 ms 12652 KB Output is correct
21 Correct 9 ms 12652 KB Output is correct
22 Correct 10 ms 12672 KB Output is correct
23 Correct 10 ms 12652 KB Output is correct
24 Correct 9 ms 12652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 12652 KB Output is correct
2 Correct 9 ms 12652 KB Output is correct
3 Correct 9 ms 12652 KB Output is correct
4 Correct 9 ms 12652 KB Output is correct
5 Correct 9 ms 12652 KB Output is correct
6 Correct 9 ms 12652 KB Output is correct
7 Correct 9 ms 12652 KB Output is correct
8 Correct 9 ms 12652 KB Output is correct
9 Correct 11 ms 12652 KB Output is correct
10 Correct 9 ms 12652 KB Output is correct
11 Correct 10 ms 12652 KB Output is correct
12 Correct 9 ms 12652 KB Output is correct
13 Correct 9 ms 12652 KB Output is correct
14 Correct 9 ms 12652 KB Output is correct
15 Correct 9 ms 12652 KB Output is correct
16 Correct 9 ms 12652 KB Output is correct
17 Correct 9 ms 12652 KB Output is correct
18 Correct 9 ms 12780 KB Output is correct
19 Correct 11 ms 12604 KB Output is correct
20 Correct 9 ms 12652 KB Output is correct
21 Correct 9 ms 12652 KB Output is correct
22 Correct 10 ms 12672 KB Output is correct
23 Correct 10 ms 12652 KB Output is correct
24 Correct 9 ms 12652 KB Output is correct
25 Correct 9 ms 12652 KB Output is correct
26 Correct 9 ms 12652 KB Output is correct
27 Correct 9 ms 12652 KB Output is correct
28 Correct 9 ms 12652 KB Output is correct
29 Correct 10 ms 12652 KB Output is correct
30 Correct 9 ms 12652 KB Output is correct
31 Correct 9 ms 12652 KB Output is correct
32 Correct 9 ms 12780 KB Output is correct
33 Correct 9 ms 12652 KB Output is correct
34 Correct 9 ms 12652 KB Output is correct
35 Correct 9 ms 12652 KB Output is correct
36 Correct 9 ms 12652 KB Output is correct
37 Correct 9 ms 12652 KB Output is correct
38 Correct 9 ms 12652 KB Output is correct
39 Correct 9 ms 12652 KB Output is correct
40 Correct 9 ms 12652 KB Output is correct
41 Correct 9 ms 12652 KB Output is correct
42 Correct 9 ms 12652 KB Output is correct
43 Correct 9 ms 12652 KB Output is correct
44 Correct 9 ms 12652 KB Output is correct
45 Correct 9 ms 12652 KB Output is correct
46 Correct 9 ms 12652 KB Output is correct
47 Correct 9 ms 12652 KB Output is correct
48 Correct 9 ms 12652 KB Output is correct
49 Correct 9 ms 12652 KB Output is correct
50 Correct 9 ms 12652 KB Output is correct
51 Correct 9 ms 12652 KB Output is correct
52 Correct 9 ms 12652 KB Output is correct
53 Correct 9 ms 12780 KB Output is correct
54 Correct 9 ms 12780 KB Output is correct
55 Correct 9 ms 12780 KB Output is correct
56 Correct 9 ms 12780 KB Output is correct
57 Correct 9 ms 12780 KB Output is correct
58 Correct 9 ms 12780 KB Output is correct
59 Correct 9 ms 12780 KB Output is correct
60 Correct 9 ms 12652 KB Output is correct
61 Correct 9 ms 12780 KB Output is correct
62 Correct 9 ms 12808 KB Output is correct
63 Correct 9 ms 12780 KB Output is correct
64 Correct 9 ms 12780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 12652 KB Output is correct
2 Correct 9 ms 12652 KB Output is correct
3 Correct 9 ms 12652 KB Output is correct
4 Correct 9 ms 12652 KB Output is correct
5 Correct 9 ms 12652 KB Output is correct
6 Correct 9 ms 12652 KB Output is correct
7 Correct 9 ms 12652 KB Output is correct
8 Correct 9 ms 12652 KB Output is correct
9 Correct 11 ms 12652 KB Output is correct
10 Correct 9 ms 12652 KB Output is correct
11 Correct 10 ms 12652 KB Output is correct
12 Correct 9 ms 12652 KB Output is correct
13 Correct 9 ms 12652 KB Output is correct
14 Correct 9 ms 12652 KB Output is correct
15 Correct 9 ms 12652 KB Output is correct
16 Correct 9 ms 12652 KB Output is correct
17 Correct 9 ms 12652 KB Output is correct
18 Correct 9 ms 12780 KB Output is correct
19 Correct 11 ms 12604 KB Output is correct
20 Correct 9 ms 12652 KB Output is correct
21 Correct 9 ms 12652 KB Output is correct
22 Correct 10 ms 12672 KB Output is correct
23 Correct 10 ms 12652 KB Output is correct
24 Correct 9 ms 12652 KB Output is correct
25 Correct 9 ms 12652 KB Output is correct
26 Correct 9 ms 12652 KB Output is correct
27 Correct 9 ms 12652 KB Output is correct
28 Correct 9 ms 12652 KB Output is correct
29 Correct 10 ms 12652 KB Output is correct
30 Correct 9 ms 12652 KB Output is correct
31 Correct 9 ms 12652 KB Output is correct
32 Correct 9 ms 12780 KB Output is correct
33 Correct 9 ms 12652 KB Output is correct
34 Correct 9 ms 12652 KB Output is correct
35 Correct 9 ms 12652 KB Output is correct
36 Correct 9 ms 12652 KB Output is correct
37 Correct 9 ms 12652 KB Output is correct
38 Correct 9 ms 12652 KB Output is correct
39 Correct 9 ms 12652 KB Output is correct
40 Correct 9 ms 12652 KB Output is correct
41 Correct 9 ms 12652 KB Output is correct
42 Correct 9 ms 12652 KB Output is correct
43 Correct 9 ms 12652 KB Output is correct
44 Correct 9 ms 12652 KB Output is correct
45 Correct 9 ms 12652 KB Output is correct
46 Correct 9 ms 12652 KB Output is correct
47 Correct 9 ms 12652 KB Output is correct
48 Correct 9 ms 12652 KB Output is correct
49 Correct 9 ms 12652 KB Output is correct
50 Correct 9 ms 12652 KB Output is correct
51 Correct 9 ms 12652 KB Output is correct
52 Correct 9 ms 12652 KB Output is correct
53 Correct 9 ms 12780 KB Output is correct
54 Correct 9 ms 12780 KB Output is correct
55 Correct 9 ms 12780 KB Output is correct
56 Correct 9 ms 12780 KB Output is correct
57 Correct 9 ms 12780 KB Output is correct
58 Correct 9 ms 12780 KB Output is correct
59 Correct 9 ms 12780 KB Output is correct
60 Correct 9 ms 12652 KB Output is correct
61 Correct 9 ms 12780 KB Output is correct
62 Correct 9 ms 12808 KB Output is correct
63 Correct 9 ms 12780 KB Output is correct
64 Correct 9 ms 12780 KB Output is correct
65 Correct 32 ms 17388 KB Output is correct
66 Correct 43 ms 18796 KB Output is correct
67 Correct 40 ms 18284 KB Output is correct
68 Correct 40 ms 18156 KB Output is correct
69 Correct 15 ms 14572 KB Output is correct
70 Correct 17 ms 14956 KB Output is correct
71 Correct 17 ms 14956 KB Output is correct
72 Correct 17 ms 14956 KB Output is correct
73 Correct 18 ms 15084 KB Output is correct
74 Correct 18 ms 15084 KB Output is correct
75 Correct 18 ms 15084 KB Output is correct
76 Correct 17 ms 15084 KB Output is correct
77 Correct 71 ms 23916 KB Output is correct
78 Correct 87 ms 25196 KB Output is correct
79 Correct 114 ms 28268 KB Output is correct
80 Correct 93 ms 25452 KB Output is correct
81 Correct 104 ms 26732 KB Output is correct
82 Correct 93 ms 25452 KB Output is correct
83 Correct 90 ms 24940 KB Output is correct
84 Correct 72 ms 21484 KB Output is correct
85 Correct 24 ms 16620 KB Output is correct
86 Correct 28 ms 17644 KB Output is correct
87 Correct 27 ms 17644 KB Output is correct
88 Correct 26 ms 17644 KB Output is correct
89 Correct 39 ms 17900 KB Output is correct
90 Correct 29 ms 17900 KB Output is correct
91 Correct 30 ms 17900 KB Output is correct
92 Correct 31 ms 18028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 12652 KB Output is correct
2 Correct 9 ms 12652 KB Output is correct
3 Correct 9 ms 12652 KB Output is correct
4 Correct 9 ms 12652 KB Output is correct
5 Correct 9 ms 12652 KB Output is correct
6 Correct 9 ms 12652 KB Output is correct
7 Correct 9 ms 12652 KB Output is correct
8 Correct 9 ms 12652 KB Output is correct
9 Correct 11 ms 12652 KB Output is correct
10 Correct 9 ms 12652 KB Output is correct
11 Correct 10 ms 12652 KB Output is correct
12 Correct 9 ms 12652 KB Output is correct
13 Correct 9 ms 12652 KB Output is correct
14 Correct 9 ms 12652 KB Output is correct
15 Correct 9 ms 12652 KB Output is correct
16 Correct 9 ms 12652 KB Output is correct
17 Correct 9 ms 12652 KB Output is correct
18 Correct 9 ms 12780 KB Output is correct
19 Correct 11 ms 12604 KB Output is correct
20 Correct 9 ms 12652 KB Output is correct
21 Correct 9 ms 12652 KB Output is correct
22 Correct 10 ms 12672 KB Output is correct
23 Correct 10 ms 12652 KB Output is correct
24 Correct 9 ms 12652 KB Output is correct
25 Correct 9 ms 12652 KB Output is correct
26 Correct 9 ms 12652 KB Output is correct
27 Correct 9 ms 12652 KB Output is correct
28 Correct 9 ms 12652 KB Output is correct
29 Correct 10 ms 12652 KB Output is correct
30 Correct 9 ms 12652 KB Output is correct
31 Correct 9 ms 12652 KB Output is correct
32 Correct 9 ms 12780 KB Output is correct
33 Correct 9 ms 12652 KB Output is correct
34 Correct 9 ms 12652 KB Output is correct
35 Correct 9 ms 12652 KB Output is correct
36 Correct 9 ms 12652 KB Output is correct
37 Correct 9 ms 12652 KB Output is correct
38 Correct 9 ms 12652 KB Output is correct
39 Correct 9 ms 12652 KB Output is correct
40 Correct 9 ms 12652 KB Output is correct
41 Correct 9 ms 12652 KB Output is correct
42 Correct 9 ms 12652 KB Output is correct
43 Correct 9 ms 12652 KB Output is correct
44 Correct 9 ms 12652 KB Output is correct
45 Correct 9 ms 12652 KB Output is correct
46 Correct 9 ms 12652 KB Output is correct
47 Correct 9 ms 12652 KB Output is correct
48 Correct 9 ms 12652 KB Output is correct
49 Correct 9 ms 12652 KB Output is correct
50 Correct 9 ms 12652 KB Output is correct
51 Correct 9 ms 12652 KB Output is correct
52 Correct 9 ms 12652 KB Output is correct
53 Correct 9 ms 12780 KB Output is correct
54 Correct 9 ms 12780 KB Output is correct
55 Correct 9 ms 12780 KB Output is correct
56 Correct 9 ms 12780 KB Output is correct
57 Correct 9 ms 12780 KB Output is correct
58 Correct 9 ms 12780 KB Output is correct
59 Correct 9 ms 12780 KB Output is correct
60 Correct 9 ms 12652 KB Output is correct
61 Correct 9 ms 12780 KB Output is correct
62 Correct 9 ms 12808 KB Output is correct
63 Correct 9 ms 12780 KB Output is correct
64 Correct 9 ms 12780 KB Output is correct
65 Correct 32 ms 17388 KB Output is correct
66 Correct 43 ms 18796 KB Output is correct
67 Correct 40 ms 18284 KB Output is correct
68 Correct 40 ms 18156 KB Output is correct
69 Correct 15 ms 14572 KB Output is correct
70 Correct 17 ms 14956 KB Output is correct
71 Correct 17 ms 14956 KB Output is correct
72 Correct 17 ms 14956 KB Output is correct
73 Correct 18 ms 15084 KB Output is correct
74 Correct 18 ms 15084 KB Output is correct
75 Correct 18 ms 15084 KB Output is correct
76 Correct 17 ms 15084 KB Output is correct
77 Correct 71 ms 23916 KB Output is correct
78 Correct 87 ms 25196 KB Output is correct
79 Correct 114 ms 28268 KB Output is correct
80 Correct 93 ms 25452 KB Output is correct
81 Correct 104 ms 26732 KB Output is correct
82 Correct 93 ms 25452 KB Output is correct
83 Correct 90 ms 24940 KB Output is correct
84 Correct 72 ms 21484 KB Output is correct
85 Correct 24 ms 16620 KB Output is correct
86 Correct 28 ms 17644 KB Output is correct
87 Correct 27 ms 17644 KB Output is correct
88 Correct 26 ms 17644 KB Output is correct
89 Correct 39 ms 17900 KB Output is correct
90 Correct 29 ms 17900 KB Output is correct
91 Correct 30 ms 17900 KB Output is correct
92 Correct 31 ms 18028 KB Output is correct
93 Correct 263 ms 59628 KB Output is correct
94 Correct 96 ms 32492 KB Output is correct
95 Correct 59 ms 26604 KB Output is correct
96 Correct 287 ms 62828 KB Output is correct
97 Correct 286 ms 61932 KB Output is correct
98 Correct 269 ms 58732 KB Output is correct
99 Correct 96 ms 29644 KB Output is correct
100 Correct 170 ms 38892 KB Output is correct
101 Correct 242 ms 46956 KB Output is correct
102 Correct 266 ms 48876 KB Output is correct
103 Correct 23 ms 18796 KB Output is correct
104 Correct 25 ms 19308 KB Output is correct
105 Correct 85 ms 30828 KB Output is correct
106 Correct 344 ms 66412 KB Output is correct
107 Correct 37 ms 24940 KB Output is correct
108 Correct 164 ms 54636 KB Output is correct
109 Correct 799 ms 131160 KB Output is correct
110 Correct 1812 ms 234988 KB Output is correct
111 Correct 264 ms 48516 KB Output is correct
112 Correct 215 ms 41708 KB Output is correct
113 Correct 209 ms 40172 KB Output is correct
114 Correct 42 ms 21100 KB Output is correct
115 Correct 54 ms 23276 KB Output is correct
116 Correct 54 ms 23276 KB Output is correct
117 Correct 52 ms 23276 KB Output is correct
118 Correct 59 ms 23788 KB Output is correct
119 Correct 62 ms 23916 KB Output is correct
120 Correct 57 ms 23788 KB Output is correct
121 Correct 55 ms 23788 KB Output is correct
122 Correct 439 ms 73452 KB Output is correct
123 Correct 660 ms 95212 KB Output is correct
124 Correct 608 ms 90092 KB Output is correct
125 Correct 570 ms 83276 KB Output is correct
126 Correct 503 ms 74732 KB Output is correct
127 Correct 332 ms 54508 KB Output is correct
128 Correct 196 ms 39660 KB Output is correct
129 Correct 106 ms 29376 KB Output is correct
130 Correct 39 ms 18796 KB Output is correct
131 Correct 91 ms 30444 KB Output is correct
132 Correct 115 ms 34924 KB Output is correct
133 Correct 124 ms 35052 KB Output is correct
134 Correct 111 ms 34924 KB Output is correct
135 Correct 135 ms 36332 KB Output is correct
136 Correct 133 ms 36332 KB Output is correct
137 Correct 133 ms 36332 KB Output is correct
138 Correct 119 ms 36332 KB Output is correct
139 Correct 130 ms 36204 KB Output is correct
140 Correct 129 ms 36076 KB Output is correct
141 Correct 121 ms 36204 KB Output is correct
142 Correct 1517 ms 196940 KB Output is correct
143 Correct 1477 ms 182968 KB Output is correct
144 Correct 1051 ms 135364 KB Output is correct
145 Correct 758 ms 101484 KB Output is correct
146 Correct 347 ms 58604 KB Output is correct
147 Correct 69 ms 24940 KB Output is correct
148 Correct 1462 ms 186476 KB Output is correct
149 Correct 1406 ms 182124 KB Output is correct
150 Correct 1662 ms 206776 KB Output is correct
151 Correct 271 ms 60668 KB Output is correct
152 Correct 303 ms 63596 KB Output is correct
153 Correct 291 ms 62828 KB Output is correct
154 Correct 292 ms 62700 KB Output is correct
155 Correct 303 ms 62700 KB Output is correct
156 Correct 276 ms 62700 KB Output is correct
157 Correct 303 ms 62700 KB Output is correct
158 Correct 302 ms 62704 KB Output is correct
159 Correct 292 ms 62572 KB Output is correct
160 Correct 302 ms 62572 KB Output is correct
161 Correct 265 ms 62572 KB Output is correct
162 Correct 282 ms 60780 KB Output is correct
163 Correct 306 ms 60780 KB Output is correct
164 Correct 296 ms 60780 KB Output is correct
165 Correct 291 ms 60780 KB Output is correct
166 Correct 272 ms 60780 KB Output is correct
167 Correct 256 ms 60780 KB Output is correct