답안 #579565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579565 2022-06-19T11:31:43 Z amunduzbaev Amusement Park (CEOI19_amusementpark) C++17
100 / 100
1548 ms 234764 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ar array
typedef int64_t ll;
//~ #define int ll
 
const int mod = 119 << 23 | 1;
const int N = 18;
map<int, int> dp[1 << N];
int is[N];
 
int bp(int a, int b){
	int c = 1;
	while(b){
		if(b & 1) c = c * 1ll * a % mod;
		a = a * 1ll * a % mod, b >>= 1;
	} return c;
}

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n, m; cin>>n>>m;
	for(int i=0;i<m;i++){
		int a, b; cin>>a>>b;
		--a, --b;
		is[a] |= (1 << b);
		is[b] |= (1 << a);
	}
	
	dp[0][0] = 1;
	for(int mask=0;mask < (1 << n);mask++){
		vector<int> rem;
		for(int i=0;i<n;i++) if(!(mask >> i & 1)) rem.push_back(i);
		for(auto& [bad, cur] : dp[mask]){
			for(auto j : rem){
				if(bad >> j & 1) continue;
				int on_j = mask | (1 << j);
				int edge_out = ((1 << n) - 1) ^ (is[j] ^ (is[j] & mask));
				int bad2 = ((bad | ((1 << j) - 1)) ^ (mask & ((1 << j) - 1))) & edge_out;
				int& res = dp[on_j][bad2];
				res = (res + cur);
				if(res >= mod) res -= mod; 
			}
		}
	}
	
	int res = dp[(1 << n) - 1][0];
	//~ cout<<res<<"\n";
	cout<<res * 1ll * bp(2, mod - 2) % mod * m % mod<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12628 KB Output is correct
2 Correct 7 ms 12584 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 8 ms 12580 KB Output is correct
5 Correct 7 ms 12500 KB Output is correct
6 Correct 7 ms 12624 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 7 ms 12500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12628 KB Output is correct
2 Correct 7 ms 12584 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 8 ms 12580 KB Output is correct
5 Correct 7 ms 12500 KB Output is correct
6 Correct 7 ms 12624 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 7 ms 12500 KB Output is correct
9 Correct 6 ms 12612 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 7 ms 12628 KB Output is correct
12 Correct 6 ms 12628 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 6 ms 12500 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 7 ms 12532 KB Output is correct
18 Correct 8 ms 12628 KB Output is correct
19 Correct 7 ms 12628 KB Output is correct
20 Correct 8 ms 12632 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 6 ms 12628 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 7 ms 12628 KB Output is correct
2 Correct 7 ms 12584 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 8 ms 12580 KB Output is correct
5 Correct 7 ms 12500 KB Output is correct
6 Correct 7 ms 12624 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 7 ms 12500 KB Output is correct
9 Correct 6 ms 12612 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 7 ms 12628 KB Output is correct
12 Correct 6 ms 12628 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 6 ms 12500 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 7 ms 12532 KB Output is correct
18 Correct 8 ms 12628 KB Output is correct
19 Correct 7 ms 12628 KB Output is correct
20 Correct 8 ms 12632 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 6 ms 12628 KB Output is correct
23 Correct 6 ms 12628 KB Output is correct
24 Correct 7 ms 12628 KB Output is correct
25 Correct 7 ms 12636 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 6 ms 12628 KB Output is correct
28 Correct 6 ms 12628 KB Output is correct
29 Correct 7 ms 12628 KB Output is correct
30 Correct 7 ms 12628 KB Output is correct
31 Correct 7 ms 12628 KB Output is correct
32 Correct 7 ms 12580 KB Output is correct
33 Correct 9 ms 12628 KB Output is correct
34 Correct 8 ms 12596 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 8 ms 12600 KB Output is correct
37 Correct 7 ms 12628 KB Output is correct
38 Correct 9 ms 12628 KB Output is correct
39 Correct 8 ms 12628 KB Output is correct
40 Correct 8 ms 12628 KB Output is correct
41 Correct 7 ms 12576 KB Output is correct
42 Correct 7 ms 12676 KB Output is correct
43 Correct 8 ms 12628 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 7 ms 12628 KB Output is correct
46 Correct 7 ms 12628 KB Output is correct
47 Correct 9 ms 12628 KB Output is correct
48 Correct 7 ms 12628 KB Output is correct
49 Correct 7 ms 12664 KB Output is correct
50 Correct 9 ms 12628 KB Output is correct
51 Correct 7 ms 12628 KB Output is correct
52 Correct 8 ms 12628 KB Output is correct
53 Correct 7 ms 12628 KB Output is correct
54 Correct 7 ms 12760 KB Output is correct
55 Correct 8 ms 12628 KB Output is correct
56 Correct 7 ms 12740 KB Output is correct
57 Correct 7 ms 12800 KB Output is correct
58 Correct 10 ms 12748 KB Output is correct
59 Correct 7 ms 12628 KB Output is correct
60 Correct 10 ms 12628 KB Output is correct
61 Correct 7 ms 12628 KB Output is correct
62 Correct 7 ms 12628 KB Output is correct
63 Correct 7 ms 12628 KB Output is correct
64 Correct 7 ms 12628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12628 KB Output is correct
2 Correct 7 ms 12584 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 8 ms 12580 KB Output is correct
5 Correct 7 ms 12500 KB Output is correct
6 Correct 7 ms 12624 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 7 ms 12500 KB Output is correct
9 Correct 6 ms 12612 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 7 ms 12628 KB Output is correct
12 Correct 6 ms 12628 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 6 ms 12500 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 7 ms 12532 KB Output is correct
18 Correct 8 ms 12628 KB Output is correct
19 Correct 7 ms 12628 KB Output is correct
20 Correct 8 ms 12632 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 6 ms 12628 KB Output is correct
23 Correct 6 ms 12628 KB Output is correct
24 Correct 7 ms 12628 KB Output is correct
25 Correct 7 ms 12636 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 6 ms 12628 KB Output is correct
28 Correct 6 ms 12628 KB Output is correct
29 Correct 7 ms 12628 KB Output is correct
30 Correct 7 ms 12628 KB Output is correct
31 Correct 7 ms 12628 KB Output is correct
32 Correct 7 ms 12580 KB Output is correct
33 Correct 9 ms 12628 KB Output is correct
34 Correct 8 ms 12596 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 8 ms 12600 KB Output is correct
37 Correct 7 ms 12628 KB Output is correct
38 Correct 9 ms 12628 KB Output is correct
39 Correct 8 ms 12628 KB Output is correct
40 Correct 8 ms 12628 KB Output is correct
41 Correct 7 ms 12576 KB Output is correct
42 Correct 7 ms 12676 KB Output is correct
43 Correct 8 ms 12628 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 7 ms 12628 KB Output is correct
46 Correct 7 ms 12628 KB Output is correct
47 Correct 9 ms 12628 KB Output is correct
48 Correct 7 ms 12628 KB Output is correct
49 Correct 7 ms 12664 KB Output is correct
50 Correct 9 ms 12628 KB Output is correct
51 Correct 7 ms 12628 KB Output is correct
52 Correct 8 ms 12628 KB Output is correct
53 Correct 7 ms 12628 KB Output is correct
54 Correct 7 ms 12760 KB Output is correct
55 Correct 8 ms 12628 KB Output is correct
56 Correct 7 ms 12740 KB Output is correct
57 Correct 7 ms 12800 KB Output is correct
58 Correct 10 ms 12748 KB Output is correct
59 Correct 7 ms 12628 KB Output is correct
60 Correct 10 ms 12628 KB Output is correct
61 Correct 7 ms 12628 KB Output is correct
62 Correct 7 ms 12628 KB Output is correct
63 Correct 7 ms 12628 KB Output is correct
64 Correct 7 ms 12628 KB Output is correct
65 Correct 29 ms 17200 KB Output is correct
66 Correct 40 ms 18768 KB Output is correct
67 Correct 36 ms 18236 KB Output is correct
68 Correct 34 ms 17916 KB Output is correct
69 Correct 15 ms 14524 KB Output is correct
70 Correct 18 ms 14904 KB Output is correct
71 Correct 17 ms 14988 KB Output is correct
72 Correct 19 ms 14876 KB Output is correct
73 Correct 17 ms 14984 KB Output is correct
74 Correct 17 ms 15060 KB Output is correct
75 Correct 17 ms 15060 KB Output is correct
76 Correct 18 ms 15060 KB Output is correct
77 Correct 64 ms 23812 KB Output is correct
78 Correct 73 ms 25060 KB Output is correct
79 Correct 92 ms 28104 KB Output is correct
80 Correct 81 ms 25420 KB Output is correct
81 Correct 91 ms 26800 KB Output is correct
82 Correct 78 ms 25292 KB Output is correct
83 Correct 77 ms 24752 KB Output is correct
84 Correct 54 ms 21292 KB Output is correct
85 Correct 25 ms 16552 KB Output is correct
86 Correct 35 ms 17492 KB Output is correct
87 Correct 30 ms 17612 KB Output is correct
88 Correct 30 ms 17520 KB Output is correct
89 Correct 28 ms 17860 KB Output is correct
90 Correct 30 ms 17780 KB Output is correct
91 Correct 29 ms 17784 KB Output is correct
92 Correct 29 ms 17820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12628 KB Output is correct
2 Correct 7 ms 12584 KB Output is correct
3 Correct 7 ms 12628 KB Output is correct
4 Correct 8 ms 12580 KB Output is correct
5 Correct 7 ms 12500 KB Output is correct
6 Correct 7 ms 12624 KB Output is correct
7 Correct 6 ms 12628 KB Output is correct
8 Correct 7 ms 12500 KB Output is correct
9 Correct 6 ms 12612 KB Output is correct
10 Correct 6 ms 12628 KB Output is correct
11 Correct 7 ms 12628 KB Output is correct
12 Correct 6 ms 12628 KB Output is correct
13 Correct 7 ms 12628 KB Output is correct
14 Correct 6 ms 12500 KB Output is correct
15 Correct 7 ms 12628 KB Output is correct
16 Correct 7 ms 12628 KB Output is correct
17 Correct 7 ms 12532 KB Output is correct
18 Correct 8 ms 12628 KB Output is correct
19 Correct 7 ms 12628 KB Output is correct
20 Correct 8 ms 12632 KB Output is correct
21 Correct 6 ms 12628 KB Output is correct
22 Correct 6 ms 12628 KB Output is correct
23 Correct 6 ms 12628 KB Output is correct
24 Correct 7 ms 12628 KB Output is correct
25 Correct 7 ms 12636 KB Output is correct
26 Correct 7 ms 12628 KB Output is correct
27 Correct 6 ms 12628 KB Output is correct
28 Correct 6 ms 12628 KB Output is correct
29 Correct 7 ms 12628 KB Output is correct
30 Correct 7 ms 12628 KB Output is correct
31 Correct 7 ms 12628 KB Output is correct
32 Correct 7 ms 12580 KB Output is correct
33 Correct 9 ms 12628 KB Output is correct
34 Correct 8 ms 12596 KB Output is correct
35 Correct 7 ms 12628 KB Output is correct
36 Correct 8 ms 12600 KB Output is correct
37 Correct 7 ms 12628 KB Output is correct
38 Correct 9 ms 12628 KB Output is correct
39 Correct 8 ms 12628 KB Output is correct
40 Correct 8 ms 12628 KB Output is correct
41 Correct 7 ms 12576 KB Output is correct
42 Correct 7 ms 12676 KB Output is correct
43 Correct 8 ms 12628 KB Output is correct
44 Correct 7 ms 12628 KB Output is correct
45 Correct 7 ms 12628 KB Output is correct
46 Correct 7 ms 12628 KB Output is correct
47 Correct 9 ms 12628 KB Output is correct
48 Correct 7 ms 12628 KB Output is correct
49 Correct 7 ms 12664 KB Output is correct
50 Correct 9 ms 12628 KB Output is correct
51 Correct 7 ms 12628 KB Output is correct
52 Correct 8 ms 12628 KB Output is correct
53 Correct 7 ms 12628 KB Output is correct
54 Correct 7 ms 12760 KB Output is correct
55 Correct 8 ms 12628 KB Output is correct
56 Correct 7 ms 12740 KB Output is correct
57 Correct 7 ms 12800 KB Output is correct
58 Correct 10 ms 12748 KB Output is correct
59 Correct 7 ms 12628 KB Output is correct
60 Correct 10 ms 12628 KB Output is correct
61 Correct 7 ms 12628 KB Output is correct
62 Correct 7 ms 12628 KB Output is correct
63 Correct 7 ms 12628 KB Output is correct
64 Correct 7 ms 12628 KB Output is correct
65 Correct 29 ms 17200 KB Output is correct
66 Correct 40 ms 18768 KB Output is correct
67 Correct 36 ms 18236 KB Output is correct
68 Correct 34 ms 17916 KB Output is correct
69 Correct 15 ms 14524 KB Output is correct
70 Correct 18 ms 14904 KB Output is correct
71 Correct 17 ms 14988 KB Output is correct
72 Correct 19 ms 14876 KB Output is correct
73 Correct 17 ms 14984 KB Output is correct
74 Correct 17 ms 15060 KB Output is correct
75 Correct 17 ms 15060 KB Output is correct
76 Correct 18 ms 15060 KB Output is correct
77 Correct 64 ms 23812 KB Output is correct
78 Correct 73 ms 25060 KB Output is correct
79 Correct 92 ms 28104 KB Output is correct
80 Correct 81 ms 25420 KB Output is correct
81 Correct 91 ms 26800 KB Output is correct
82 Correct 78 ms 25292 KB Output is correct
83 Correct 77 ms 24752 KB Output is correct
84 Correct 54 ms 21292 KB Output is correct
85 Correct 25 ms 16552 KB Output is correct
86 Correct 35 ms 17492 KB Output is correct
87 Correct 30 ms 17612 KB Output is correct
88 Correct 30 ms 17520 KB Output is correct
89 Correct 28 ms 17860 KB Output is correct
90 Correct 30 ms 17780 KB Output is correct
91 Correct 29 ms 17784 KB Output is correct
92 Correct 29 ms 17820 KB Output is correct
93 Correct 258 ms 59500 KB Output is correct
94 Correct 130 ms 32424 KB Output is correct
95 Correct 94 ms 26508 KB Output is correct
96 Correct 271 ms 62604 KB Output is correct
97 Correct 266 ms 61956 KB Output is correct
98 Correct 251 ms 58576 KB Output is correct
99 Correct 97 ms 29388 KB Output is correct
100 Correct 157 ms 38876 KB Output is correct
101 Correct 212 ms 46796 KB Output is correct
102 Correct 245 ms 48620 KB Output is correct
103 Correct 43 ms 18768 KB Output is correct
104 Correct 46 ms 19296 KB Output is correct
105 Correct 95 ms 30836 KB Output is correct
106 Correct 313 ms 66512 KB Output is correct
107 Correct 88 ms 24928 KB Output is correct
108 Correct 191 ms 54536 KB Output is correct
109 Correct 762 ms 130968 KB Output is correct
110 Correct 1548 ms 234764 KB Output is correct
111 Correct 235 ms 48624 KB Output is correct
112 Correct 196 ms 41576 KB Output is correct
113 Correct 181 ms 40096 KB Output is correct
114 Correct 54 ms 21072 KB Output is correct
115 Correct 60 ms 23112 KB Output is correct
116 Correct 55 ms 23096 KB Output is correct
117 Correct 53 ms 23076 KB Output is correct
118 Correct 55 ms 23652 KB Output is correct
119 Correct 64 ms 23732 KB Output is correct
120 Correct 58 ms 23756 KB Output is correct
121 Correct 55 ms 23688 KB Output is correct
122 Correct 395 ms 73252 KB Output is correct
123 Correct 546 ms 95056 KB Output is correct
124 Correct 537 ms 90032 KB Output is correct
125 Correct 468 ms 83024 KB Output is correct
126 Correct 413 ms 74744 KB Output is correct
127 Correct 263 ms 54388 KB Output is correct
128 Correct 176 ms 39516 KB Output is correct
129 Correct 149 ms 29224 KB Output is correct
130 Correct 57 ms 18772 KB Output is correct
131 Correct 115 ms 30300 KB Output is correct
132 Correct 113 ms 34896 KB Output is correct
133 Correct 135 ms 34944 KB Output is correct
134 Correct 115 ms 34872 KB Output is correct
135 Correct 121 ms 36176 KB Output is correct
136 Correct 128 ms 36312 KB Output is correct
137 Correct 133 ms 36180 KB Output is correct
138 Correct 115 ms 36216 KB Output is correct
139 Correct 119 ms 35968 KB Output is correct
140 Correct 152 ms 35960 KB Output is correct
141 Correct 152 ms 36044 KB Output is correct
142 Correct 1285 ms 196836 KB Output is correct
143 Correct 1210 ms 182896 KB Output is correct
144 Correct 883 ms 135076 KB Output is correct
145 Correct 647 ms 101452 KB Output is correct
146 Correct 292 ms 58444 KB Output is correct
147 Correct 105 ms 24940 KB Output is correct
148 Correct 1211 ms 186460 KB Output is correct
149 Correct 1205 ms 181948 KB Output is correct
150 Correct 1436 ms 206732 KB Output is correct
151 Correct 247 ms 60460 KB Output is correct
152 Correct 279 ms 63736 KB Output is correct
153 Correct 265 ms 62680 KB Output is correct
154 Correct 273 ms 62632 KB Output is correct
155 Correct 283 ms 62536 KB Output is correct
156 Correct 256 ms 62704 KB Output is correct
157 Correct 309 ms 62788 KB Output is correct
158 Correct 257 ms 62588 KB Output is correct
159 Correct 281 ms 62380 KB Output is correct
160 Correct 278 ms 62412 KB Output is correct
161 Correct 251 ms 62416 KB Output is correct
162 Correct 264 ms 60644 KB Output is correct
163 Correct 283 ms 60696 KB Output is correct
164 Correct 278 ms 60588 KB Output is correct
165 Correct 279 ms 60708 KB Output is correct
166 Correct 251 ms 60668 KB Output is correct
167 Correct 250 ms 60596 KB Output is correct