답안 #742060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742060 2023-05-15T13:40:41 Z nishkarsh Amusement Park (CEOI19_amusementpark) C++14
100 / 100
699 ms 3784 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 18;
const int mod = 998244353;
bool isindep[1<<N];
ll dp[1<<N];
int popcnt[1<<N];
int undirected_edge[N];
int main(){
	int n,m,a,b;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		cin >> a >> b;
		a--;b--;
		undirected_edge[a] ^= (1<<b);
		undirected_edge[b] ^= (1<<a);
	}
	for(int i = 0; i < (1<<n); i++){
		int edges = 0;
		for(int j = 0; j < n; j++){
			if(i&(1<<j)){
				popcnt[i]++;
				edges |= undirected_edge[j];
			}
		}
		if((edges&i) == 0) isindep[i] = true;
	}
	dp[0] = 1;
	for(int i = 1; i < (1<<n); i++){
		for(int j = i; j > 0; j = (j-1)&i){
			if(isindep[j]){
				if(popcnt[j]&1) dp[i] += dp[i^j];
				else dp[i] -= dp[i^j];
			}
		}
		dp[i]%=mod;
      	if(dp[i] < 0) dp[i] += mod;
	}
	ll ans = dp[(1<<n)-1];
	if(ans&1) ans += mod;
	ans >>= 1;
	ans *= m; ans %= mod;
	cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 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 1 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 0 ms 212 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 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 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 212 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 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 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 212 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 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 1 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 0 ms 212 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 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 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 212 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 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 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 212 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 468 KB Output is correct
67 Correct 8 ms 468 KB Output is correct
68 Correct 9 ms 468 KB Output is correct
69 Correct 10 ms 460 KB Output is correct
70 Correct 9 ms 468 KB Output is correct
71 Correct 8 ms 440 KB Output is correct
72 Correct 7 ms 464 KB Output is correct
73 Correct 8 ms 468 KB Output is correct
74 Correct 8 ms 468 KB Output is correct
75 Correct 7 ms 468 KB Output is correct
76 Correct 7 ms 468 KB Output is correct
77 Correct 28 ms 688 KB Output is correct
78 Correct 25 ms 644 KB Output is correct
79 Correct 24 ms 716 KB Output is correct
80 Correct 21 ms 644 KB Output is correct
81 Correct 20 ms 724 KB Output is correct
82 Correct 19 ms 596 KB Output is correct
83 Correct 19 ms 712 KB Output is correct
84 Correct 18 ms 704 KB Output is correct
85 Correct 27 ms 720 KB Output is correct
86 Correct 25 ms 656 KB Output is correct
87 Correct 22 ms 592 KB Output is correct
88 Correct 18 ms 708 KB Output is correct
89 Correct 24 ms 600 KB Output is correct
90 Correct 21 ms 684 KB Output is correct
91 Correct 19 ms 672 KB Output is correct
92 Correct 17 ms 660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 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 1 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 0 ms 212 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 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 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 212 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 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 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 212 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 468 KB Output is correct
67 Correct 8 ms 468 KB Output is correct
68 Correct 9 ms 468 KB Output is correct
69 Correct 10 ms 460 KB Output is correct
70 Correct 9 ms 468 KB Output is correct
71 Correct 8 ms 440 KB Output is correct
72 Correct 7 ms 464 KB Output is correct
73 Correct 8 ms 468 KB Output is correct
74 Correct 8 ms 468 KB Output is correct
75 Correct 7 ms 468 KB Output is correct
76 Correct 7 ms 468 KB Output is correct
77 Correct 28 ms 688 KB Output is correct
78 Correct 25 ms 644 KB Output is correct
79 Correct 24 ms 716 KB Output is correct
80 Correct 21 ms 644 KB Output is correct
81 Correct 20 ms 724 KB Output is correct
82 Correct 19 ms 596 KB Output is correct
83 Correct 19 ms 712 KB Output is correct
84 Correct 18 ms 704 KB Output is correct
85 Correct 27 ms 720 KB Output is correct
86 Correct 25 ms 656 KB Output is correct
87 Correct 22 ms 592 KB Output is correct
88 Correct 18 ms 708 KB Output is correct
89 Correct 24 ms 600 KB Output is correct
90 Correct 21 ms 684 KB Output is correct
91 Correct 19 ms 672 KB Output is correct
92 Correct 17 ms 660 KB Output is correct
93 Correct 664 ms 3592 KB Output is correct
94 Correct 683 ms 3576 KB Output is correct
95 Correct 664 ms 3496 KB Output is correct
96 Correct 614 ms 3612 KB Output is correct
97 Correct 547 ms 3612 KB Output is correct
98 Correct 562 ms 3604 KB Output is correct
99 Correct 78 ms 1104 KB Output is correct
100 Correct 66 ms 1104 KB Output is correct
101 Correct 64 ms 1076 KB Output is correct
102 Correct 59 ms 1100 KB Output is correct
103 Correct 223 ms 1868 KB Output is correct
104 Correct 200 ms 1924 KB Output is correct
105 Correct 213 ms 1960 KB Output is correct
106 Correct 182 ms 1904 KB Output is correct
107 Correct 699 ms 3784 KB Output is correct
108 Correct 562 ms 3572 KB Output is correct
109 Correct 519 ms 3604 KB Output is correct
110 Correct 462 ms 3436 KB Output is correct
111 Correct 53 ms 1068 KB Output is correct
112 Correct 49 ms 1076 KB Output is correct
113 Correct 48 ms 1088 KB Output is correct
114 Correct 76 ms 1116 KB Output is correct
115 Correct 72 ms 1228 KB Output is correct
116 Correct 64 ms 1024 KB Output is correct
117 Correct 52 ms 1012 KB Output is correct
118 Correct 68 ms 1072 KB Output is correct
119 Correct 64 ms 1100 KB Output is correct
120 Correct 54 ms 1020 KB Output is correct
121 Correct 50 ms 980 KB Output is correct
122 Correct 169 ms 1908 KB Output is correct
123 Correct 152 ms 1880 KB Output is correct
124 Correct 145 ms 1880 KB Output is correct
125 Correct 144 ms 1888 KB Output is correct
126 Correct 131 ms 1764 KB Output is correct
127 Correct 124 ms 1868 KB Output is correct
128 Correct 115 ms 1980 KB Output is correct
129 Correct 110 ms 1848 KB Output is correct
130 Correct 105 ms 1740 KB Output is correct
131 Correct 226 ms 1896 KB Output is correct
132 Correct 228 ms 1924 KB Output is correct
133 Correct 193 ms 1896 KB Output is correct
134 Correct 159 ms 1868 KB Output is correct
135 Correct 199 ms 2024 KB Output is correct
136 Correct 175 ms 1868 KB Output is correct
137 Correct 155 ms 1844 KB Output is correct
138 Correct 133 ms 1824 KB Output is correct
139 Correct 179 ms 1948 KB Output is correct
140 Correct 158 ms 1964 KB Output is correct
141 Correct 125 ms 1740 KB Output is correct
142 Correct 408 ms 3448 KB Output is correct
143 Correct 383 ms 3364 KB Output is correct
144 Correct 372 ms 3404 KB Output is correct
145 Correct 350 ms 3344 KB Output is correct
146 Correct 320 ms 3396 KB Output is correct
147 Correct 292 ms 3384 KB Output is correct
148 Correct 419 ms 3576 KB Output is correct
149 Correct 407 ms 3492 KB Output is correct
150 Correct 405 ms 3452 KB Output is correct
151 Correct 412 ms 3412 KB Output is correct
152 Correct 426 ms 3424 KB Output is correct
153 Correct 606 ms 3564 KB Output is correct
154 Correct 589 ms 3660 KB Output is correct
155 Correct 484 ms 3592 KB Output is correct
156 Correct 394 ms 3596 KB Output is correct
157 Correct 531 ms 3416 KB Output is correct
158 Correct 464 ms 3580 KB Output is correct
159 Correct 545 ms 3660 KB Output is correct
160 Correct 450 ms 3392 KB Output is correct
161 Correct 357 ms 3376 KB Output is correct
162 Correct 499 ms 3616 KB Output is correct
163 Correct 446 ms 3564 KB Output is correct
164 Correct 411 ms 3404 KB Output is correct
165 Correct 400 ms 3352 KB Output is correct
166 Correct 364 ms 3312 KB Output is correct
167 Correct 337 ms 3336 KB Output is correct