Submission #441144

# Submission time Handle Problem Language Result Execution time Memory
441144 2021-07-04T11:44:43 Z Autron Amusement Park (CEOI19_amusementpark) C++14
100 / 100
2157 ms 308884 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define MOD 998244353

int adj[20];
map<int, int> dp[1<<18];

int32_t main(){
	int n, m;
	cin>>n>>m;
	for(int i=1;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 mask=0;mask<(1<<n);++mask){
		for(auto it:dp[mask]){
			int mask2=it.first;
			int nr=it.second;
			for(int x=0;x<n;++x){
				if(mask2&(1<<x)){
					int aux=mask2;
					aux=aux&(((1<<n)-1)-((1<<(x+1))-1));
					aux=aux|((adj[x]|mask)^mask);
					dp[mask|(1<<x)][aux]+=nr;
					dp[mask|(1<<x)][aux]%=MOD;
				}
			}
		}
	}
	int sol=dp[(1<<n)-1][0];
	sol=(sol*m)%MOD;
	sol=(sol*(MOD+1)/2)%MOD;
	cout<<sol<<"\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 12492 KB Output is correct
2 Correct 8 ms 12492 KB Output is correct
3 Correct 8 ms 12492 KB Output is correct
4 Correct 8 ms 12604 KB Output is correct
5 Correct 9 ms 12512 KB Output is correct
6 Correct 8 ms 12492 KB Output is correct
7 Correct 8 ms 12620 KB Output is correct
8 Correct 8 ms 12492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 12492 KB Output is correct
2 Correct 8 ms 12492 KB Output is correct
3 Correct 8 ms 12492 KB Output is correct
4 Correct 8 ms 12604 KB Output is correct
5 Correct 9 ms 12512 KB Output is correct
6 Correct 8 ms 12492 KB Output is correct
7 Correct 8 ms 12620 KB Output is correct
8 Correct 8 ms 12492 KB Output is correct
9 Correct 8 ms 12604 KB Output is correct
10 Correct 8 ms 12492 KB Output is correct
11 Correct 8 ms 12604 KB Output is correct
12 Correct 8 ms 12492 KB Output is correct
13 Correct 9 ms 12576 KB Output is correct
14 Correct 8 ms 12600 KB Output is correct
15 Correct 8 ms 12492 KB Output is correct
16 Correct 8 ms 12492 KB Output is correct
17 Correct 8 ms 12492 KB Output is correct
18 Correct 8 ms 12608 KB Output is correct
19 Correct 8 ms 12492 KB Output is correct
20 Correct 9 ms 12608 KB Output is correct
21 Correct 8 ms 12492 KB Output is correct
22 Correct 8 ms 12544 KB Output is correct
23 Correct 8 ms 12492 KB Output is correct
24 Correct 8 ms 12492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 12492 KB Output is correct
2 Correct 8 ms 12492 KB Output is correct
3 Correct 8 ms 12492 KB Output is correct
4 Correct 8 ms 12604 KB Output is correct
5 Correct 9 ms 12512 KB Output is correct
6 Correct 8 ms 12492 KB Output is correct
7 Correct 8 ms 12620 KB Output is correct
8 Correct 8 ms 12492 KB Output is correct
9 Correct 8 ms 12604 KB Output is correct
10 Correct 8 ms 12492 KB Output is correct
11 Correct 8 ms 12604 KB Output is correct
12 Correct 8 ms 12492 KB Output is correct
13 Correct 9 ms 12576 KB Output is correct
14 Correct 8 ms 12600 KB Output is correct
15 Correct 8 ms 12492 KB Output is correct
16 Correct 8 ms 12492 KB Output is correct
17 Correct 8 ms 12492 KB Output is correct
18 Correct 8 ms 12608 KB Output is correct
19 Correct 8 ms 12492 KB Output is correct
20 Correct 9 ms 12608 KB Output is correct
21 Correct 8 ms 12492 KB Output is correct
22 Correct 8 ms 12544 KB Output is correct
23 Correct 8 ms 12492 KB Output is correct
24 Correct 8 ms 12492 KB Output is correct
25 Correct 8 ms 12500 KB Output is correct
26 Correct 8 ms 12620 KB Output is correct
27 Correct 8 ms 12492 KB Output is correct
28 Correct 8 ms 12512 KB Output is correct
29 Correct 8 ms 12624 KB Output is correct
30 Correct 8 ms 12492 KB Output is correct
31 Correct 8 ms 12492 KB Output is correct
32 Correct 9 ms 12628 KB Output is correct
33 Correct 9 ms 12532 KB Output is correct
34 Correct 8 ms 12600 KB Output is correct
35 Correct 8 ms 12640 KB Output is correct
36 Correct 8 ms 12620 KB Output is correct
37 Correct 8 ms 12620 KB Output is correct
38 Correct 8 ms 12492 KB Output is correct
39 Correct 8 ms 12604 KB Output is correct
40 Correct 8 ms 12620 KB Output is correct
41 Correct 8 ms 12620 KB Output is correct
42 Correct 8 ms 12620 KB Output is correct
43 Correct 8 ms 12620 KB Output is correct
44 Correct 8 ms 12612 KB Output is correct
45 Correct 9 ms 12620 KB Output is correct
46 Correct 8 ms 12620 KB Output is correct
47 Correct 9 ms 12620 KB Output is correct
48 Correct 8 ms 12548 KB Output is correct
49 Correct 8 ms 12660 KB Output is correct
50 Correct 8 ms 12620 KB Output is correct
51 Correct 8 ms 12620 KB Output is correct
52 Correct 8 ms 12620 KB Output is correct
53 Correct 8 ms 12668 KB Output is correct
54 Correct 9 ms 12748 KB Output is correct
55 Correct 8 ms 12748 KB Output is correct
56 Correct 9 ms 12748 KB Output is correct
57 Correct 9 ms 12836 KB Output is correct
58 Correct 10 ms 12748 KB Output is correct
59 Correct 9 ms 12668 KB Output is correct
60 Correct 8 ms 12564 KB Output is correct
61 Correct 8 ms 12620 KB Output is correct
62 Correct 8 ms 12748 KB Output is correct
63 Correct 9 ms 12748 KB Output is correct
64 Correct 8 ms 12748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 12492 KB Output is correct
2 Correct 8 ms 12492 KB Output is correct
3 Correct 8 ms 12492 KB Output is correct
4 Correct 8 ms 12604 KB Output is correct
5 Correct 9 ms 12512 KB Output is correct
6 Correct 8 ms 12492 KB Output is correct
7 Correct 8 ms 12620 KB Output is correct
8 Correct 8 ms 12492 KB Output is correct
9 Correct 8 ms 12604 KB Output is correct
10 Correct 8 ms 12492 KB Output is correct
11 Correct 8 ms 12604 KB Output is correct
12 Correct 8 ms 12492 KB Output is correct
13 Correct 9 ms 12576 KB Output is correct
14 Correct 8 ms 12600 KB Output is correct
15 Correct 8 ms 12492 KB Output is correct
16 Correct 8 ms 12492 KB Output is correct
17 Correct 8 ms 12492 KB Output is correct
18 Correct 8 ms 12608 KB Output is correct
19 Correct 8 ms 12492 KB Output is correct
20 Correct 9 ms 12608 KB Output is correct
21 Correct 8 ms 12492 KB Output is correct
22 Correct 8 ms 12544 KB Output is correct
23 Correct 8 ms 12492 KB Output is correct
24 Correct 8 ms 12492 KB Output is correct
25 Correct 8 ms 12500 KB Output is correct
26 Correct 8 ms 12620 KB Output is correct
27 Correct 8 ms 12492 KB Output is correct
28 Correct 8 ms 12512 KB Output is correct
29 Correct 8 ms 12624 KB Output is correct
30 Correct 8 ms 12492 KB Output is correct
31 Correct 8 ms 12492 KB Output is correct
32 Correct 9 ms 12628 KB Output is correct
33 Correct 9 ms 12532 KB Output is correct
34 Correct 8 ms 12600 KB Output is correct
35 Correct 8 ms 12640 KB Output is correct
36 Correct 8 ms 12620 KB Output is correct
37 Correct 8 ms 12620 KB Output is correct
38 Correct 8 ms 12492 KB Output is correct
39 Correct 8 ms 12604 KB Output is correct
40 Correct 8 ms 12620 KB Output is correct
41 Correct 8 ms 12620 KB Output is correct
42 Correct 8 ms 12620 KB Output is correct
43 Correct 8 ms 12620 KB Output is correct
44 Correct 8 ms 12612 KB Output is correct
45 Correct 9 ms 12620 KB Output is correct
46 Correct 8 ms 12620 KB Output is correct
47 Correct 9 ms 12620 KB Output is correct
48 Correct 8 ms 12548 KB Output is correct
49 Correct 8 ms 12660 KB Output is correct
50 Correct 8 ms 12620 KB Output is correct
51 Correct 8 ms 12620 KB Output is correct
52 Correct 8 ms 12620 KB Output is correct
53 Correct 8 ms 12668 KB Output is correct
54 Correct 9 ms 12748 KB Output is correct
55 Correct 8 ms 12748 KB Output is correct
56 Correct 9 ms 12748 KB Output is correct
57 Correct 9 ms 12836 KB Output is correct
58 Correct 10 ms 12748 KB Output is correct
59 Correct 9 ms 12668 KB Output is correct
60 Correct 8 ms 12564 KB Output is correct
61 Correct 8 ms 12620 KB Output is correct
62 Correct 8 ms 12748 KB Output is correct
63 Correct 9 ms 12748 KB Output is correct
64 Correct 8 ms 12748 KB Output is correct
65 Correct 38 ms 18836 KB Output is correct
66 Correct 51 ms 20832 KB Output is correct
67 Correct 47 ms 20076 KB Output is correct
68 Correct 48 ms 19704 KB Output is correct
69 Correct 16 ms 15052 KB Output is correct
70 Correct 19 ms 15628 KB Output is correct
71 Correct 19 ms 15728 KB Output is correct
72 Correct 19 ms 15664 KB Output is correct
73 Correct 19 ms 15820 KB Output is correct
74 Correct 20 ms 15784 KB Output is correct
75 Correct 21 ms 15960 KB Output is correct
76 Correct 19 ms 15820 KB Output is correct
77 Correct 81 ms 27436 KB Output is correct
78 Correct 95 ms 29172 KB Output is correct
79 Correct 130 ms 33356 KB Output is correct
80 Correct 109 ms 29636 KB Output is correct
81 Correct 125 ms 31356 KB Output is correct
82 Correct 108 ms 29460 KB Output is correct
83 Correct 103 ms 28868 KB Output is correct
84 Correct 73 ms 24132 KB Output is correct
85 Correct 26 ms 17976 KB Output is correct
86 Correct 32 ms 19180 KB Output is correct
87 Correct 33 ms 19140 KB Output is correct
88 Correct 31 ms 19212 KB Output is correct
89 Correct 35 ms 19476 KB Output is correct
90 Correct 37 ms 19468 KB Output is correct
91 Correct 34 ms 19568 KB Output is correct
92 Correct 35 ms 19524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 12492 KB Output is correct
2 Correct 8 ms 12492 KB Output is correct
3 Correct 8 ms 12492 KB Output is correct
4 Correct 8 ms 12604 KB Output is correct
5 Correct 9 ms 12512 KB Output is correct
6 Correct 8 ms 12492 KB Output is correct
7 Correct 8 ms 12620 KB Output is correct
8 Correct 8 ms 12492 KB Output is correct
9 Correct 8 ms 12604 KB Output is correct
10 Correct 8 ms 12492 KB Output is correct
11 Correct 8 ms 12604 KB Output is correct
12 Correct 8 ms 12492 KB Output is correct
13 Correct 9 ms 12576 KB Output is correct
14 Correct 8 ms 12600 KB Output is correct
15 Correct 8 ms 12492 KB Output is correct
16 Correct 8 ms 12492 KB Output is correct
17 Correct 8 ms 12492 KB Output is correct
18 Correct 8 ms 12608 KB Output is correct
19 Correct 8 ms 12492 KB Output is correct
20 Correct 9 ms 12608 KB Output is correct
21 Correct 8 ms 12492 KB Output is correct
22 Correct 8 ms 12544 KB Output is correct
23 Correct 8 ms 12492 KB Output is correct
24 Correct 8 ms 12492 KB Output is correct
25 Correct 8 ms 12500 KB Output is correct
26 Correct 8 ms 12620 KB Output is correct
27 Correct 8 ms 12492 KB Output is correct
28 Correct 8 ms 12512 KB Output is correct
29 Correct 8 ms 12624 KB Output is correct
30 Correct 8 ms 12492 KB Output is correct
31 Correct 8 ms 12492 KB Output is correct
32 Correct 9 ms 12628 KB Output is correct
33 Correct 9 ms 12532 KB Output is correct
34 Correct 8 ms 12600 KB Output is correct
35 Correct 8 ms 12640 KB Output is correct
36 Correct 8 ms 12620 KB Output is correct
37 Correct 8 ms 12620 KB Output is correct
38 Correct 8 ms 12492 KB Output is correct
39 Correct 8 ms 12604 KB Output is correct
40 Correct 8 ms 12620 KB Output is correct
41 Correct 8 ms 12620 KB Output is correct
42 Correct 8 ms 12620 KB Output is correct
43 Correct 8 ms 12620 KB Output is correct
44 Correct 8 ms 12612 KB Output is correct
45 Correct 9 ms 12620 KB Output is correct
46 Correct 8 ms 12620 KB Output is correct
47 Correct 9 ms 12620 KB Output is correct
48 Correct 8 ms 12548 KB Output is correct
49 Correct 8 ms 12660 KB Output is correct
50 Correct 8 ms 12620 KB Output is correct
51 Correct 8 ms 12620 KB Output is correct
52 Correct 8 ms 12620 KB Output is correct
53 Correct 8 ms 12668 KB Output is correct
54 Correct 9 ms 12748 KB Output is correct
55 Correct 8 ms 12748 KB Output is correct
56 Correct 9 ms 12748 KB Output is correct
57 Correct 9 ms 12836 KB Output is correct
58 Correct 10 ms 12748 KB Output is correct
59 Correct 9 ms 12668 KB Output is correct
60 Correct 8 ms 12564 KB Output is correct
61 Correct 8 ms 12620 KB Output is correct
62 Correct 8 ms 12748 KB Output is correct
63 Correct 9 ms 12748 KB Output is correct
64 Correct 8 ms 12748 KB Output is correct
65 Correct 38 ms 18836 KB Output is correct
66 Correct 51 ms 20832 KB Output is correct
67 Correct 47 ms 20076 KB Output is correct
68 Correct 48 ms 19704 KB Output is correct
69 Correct 16 ms 15052 KB Output is correct
70 Correct 19 ms 15628 KB Output is correct
71 Correct 19 ms 15728 KB Output is correct
72 Correct 19 ms 15664 KB Output is correct
73 Correct 19 ms 15820 KB Output is correct
74 Correct 20 ms 15784 KB Output is correct
75 Correct 21 ms 15960 KB Output is correct
76 Correct 19 ms 15820 KB Output is correct
77 Correct 81 ms 27436 KB Output is correct
78 Correct 95 ms 29172 KB Output is correct
79 Correct 130 ms 33356 KB Output is correct
80 Correct 109 ms 29636 KB Output is correct
81 Correct 125 ms 31356 KB Output is correct
82 Correct 108 ms 29460 KB Output is correct
83 Correct 103 ms 28868 KB Output is correct
84 Correct 73 ms 24132 KB Output is correct
85 Correct 26 ms 17976 KB Output is correct
86 Correct 32 ms 19180 KB Output is correct
87 Correct 33 ms 19140 KB Output is correct
88 Correct 31 ms 19212 KB Output is correct
89 Correct 35 ms 19476 KB Output is correct
90 Correct 37 ms 19468 KB Output is correct
91 Correct 34 ms 19568 KB Output is correct
92 Correct 35 ms 19524 KB Output is correct
93 Correct 326 ms 75300 KB Output is correct
94 Correct 124 ms 38936 KB Output is correct
95 Correct 62 ms 31040 KB Output is correct
96 Correct 346 ms 79184 KB Output is correct
97 Correct 348 ms 78348 KB Output is correct
98 Correct 312 ms 73992 KB Output is correct
99 Correct 118 ms 35248 KB Output is correct
100 Correct 194 ms 47516 KB Output is correct
101 Correct 292 ms 58180 KB Output is correct
102 Correct 320 ms 60920 KB Output is correct
103 Correct 23 ms 20812 KB Output is correct
104 Correct 27 ms 21484 KB Output is correct
105 Correct 97 ms 36792 KB Output is correct
106 Correct 411 ms 84432 KB Output is correct
107 Correct 39 ms 29000 KB Output is correct
108 Correct 201 ms 68588 KB Output is correct
109 Correct 965 ms 170552 KB Output is correct
110 Correct 2157 ms 308884 KB Output is correct
111 Correct 319 ms 60428 KB Output is correct
112 Correct 251 ms 51252 KB Output is correct
113 Correct 246 ms 49160 KB Output is correct
114 Correct 53 ms 23788 KB Output is correct
115 Correct 68 ms 26692 KB Output is correct
116 Correct 70 ms 26692 KB Output is correct
117 Correct 66 ms 26612 KB Output is correct
118 Correct 71 ms 27456 KB Output is correct
119 Correct 73 ms 27464 KB Output is correct
120 Correct 73 ms 27388 KB Output is correct
121 Correct 72 ms 27436 KB Output is correct
122 Correct 527 ms 93380 KB Output is correct
123 Correct 767 ms 122424 KB Output is correct
124 Correct 711 ms 115708 KB Output is correct
125 Correct 674 ms 106572 KB Output is correct
126 Correct 670 ms 95420 KB Output is correct
127 Correct 451 ms 68324 KB Output is correct
128 Correct 267 ms 48404 KB Output is correct
129 Correct 132 ms 34688 KB Output is correct
130 Correct 43 ms 20724 KB Output is correct
131 Correct 121 ms 36180 KB Output is correct
132 Correct 166 ms 42264 KB Output is correct
133 Correct 165 ms 42340 KB Output is correct
134 Correct 157 ms 42336 KB Output is correct
135 Correct 176 ms 44020 KB Output is correct
136 Correct 182 ms 44096 KB Output is correct
137 Correct 189 ms 44124 KB Output is correct
138 Correct 166 ms 44012 KB Output is correct
139 Correct 161 ms 43832 KB Output is correct
140 Correct 179 ms 43800 KB Output is correct
141 Correct 167 ms 43896 KB Output is correct
142 Correct 1890 ms 258128 KB Output is correct
143 Correct 1772 ms 239448 KB Output is correct
144 Correct 1259 ms 175776 KB Output is correct
145 Correct 940 ms 130996 KB Output is correct
146 Correct 423 ms 73668 KB Output is correct
147 Correct 85 ms 28996 KB Output is correct
148 Correct 1749 ms 244376 KB Output is correct
149 Correct 1716 ms 238408 KB Output is correct
150 Correct 2146 ms 271336 KB Output is correct
151 Correct 356 ms 76368 KB Output is correct
152 Correct 397 ms 80504 KB Output is correct
153 Correct 392 ms 79220 KB Output is correct
154 Correct 359 ms 79272 KB Output is correct
155 Correct 436 ms 79244 KB Output is correct
156 Correct 344 ms 79176 KB Output is correct
157 Correct 378 ms 79276 KB Output is correct
158 Correct 402 ms 79248 KB Output is correct
159 Correct 407 ms 79012 KB Output is correct
160 Correct 408 ms 78988 KB Output is correct
161 Correct 343 ms 79004 KB Output is correct
162 Correct 361 ms 76656 KB Output is correct
163 Correct 385 ms 76756 KB Output is correct
164 Correct 394 ms 76704 KB Output is correct
165 Correct 386 ms 76600 KB Output is correct
166 Correct 356 ms 76620 KB Output is correct
167 Correct 314 ms 76708 KB Output is correct