Submission #699186

# Submission time Handle Problem Language Result Execution time Memory
699186 2023-02-16T01:52:08 Z vjudge1 Amusement Park (CEOI19_amusementpark) C++17
100 / 100
1020 ms 2648 KB
/* ...... */

#include <bits/stdc++.h>
using namespace std;

#define inl inline
#define all(p) begin (p), end (p)
typedef long long ll;
using pint = pair <int, int>;
#define ctz __builtin_ctz

constexpr int N = 18, P = 998244353;
int n, m, x, y, e[N]; ll f[1<<N]; bool g[1<<N];
vector <pint> l1, l2;

int main () {
	/*  */
	scanf ("%d%d", &n, &m); g[0] = 1;
	for (int i = 1; i <= m; ++i)
		scanf ("%d%d", &x, &y), --x, --y,
		e[x] |= 1<<y, e[y] |= 1<<x;
	for (int s = 1, msk; s < 1<<n; ++s)
		x = ctz (s), msk = s ^ (1<<x),
		g[s] = g[msk] && !(e[x] & msk);
	for (int s = 0; s < 1<<n; ++s) {
		(f[s] += g[s]) %= P; int sube = 0, msk;
		for (x = 0; x < n; ++x)
			if ((s >> x) & 1) sube |= e[x];
		sube &= ((1<<n)-1) ^ s;
		msk = sube; while (msk)
			f[s | msk] += f[s] * g[msk] *
				(P - 1 + (__builtin_parity (msk)<<1)) % P,
			(--msk) &= sube;
	}
	printf ("%lld", f[(1<<n)-1] * m % P * (P+1ll>>1) % P);

	return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:35:42: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |  printf ("%lld", f[(1<<n)-1] * m % P * (P+1ll>>1) % P);
      |                                         ~^~~~
amusementpark.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf ("%d%d", &n, &m); g[0] = 1;
      |  ~~~~~~^~~~~~~~~~~~~~~~
amusementpark.cpp:20:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf ("%d%d", &x, &y), --x, --y,
      |   ~~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 0 ms 216 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 0 ms 216 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 1 ms 216 KB Output is correct
13 Correct 0 ms 224 KB Output is correct
14 Correct 1 ms 220 KB Output is correct
15 Correct 1 ms 220 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 0 ms 224 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 1 ms 224 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 304 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 304 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 0 ms 216 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 1 ms 216 KB Output is correct
13 Correct 0 ms 224 KB Output is correct
14 Correct 1 ms 220 KB Output is correct
15 Correct 1 ms 220 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 0 ms 224 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 1 ms 224 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 304 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 304 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 308 KB Output is correct
26 Correct 1 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 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 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 0 ms 300 KB Output is correct
36 Correct 1 ms 312 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 304 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 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 308 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 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 0 ms 216 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 1 ms 216 KB Output is correct
13 Correct 0 ms 224 KB Output is correct
14 Correct 1 ms 220 KB Output is correct
15 Correct 1 ms 220 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 0 ms 224 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 1 ms 224 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 304 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 304 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 308 KB Output is correct
26 Correct 1 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 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 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 0 ms 300 KB Output is correct
36 Correct 1 ms 312 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 304 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 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 308 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 312 KB Output is correct
65 Correct 10 ms 340 KB Output is correct
66 Correct 10 ms 476 KB Output is correct
67 Correct 11 ms 428 KB Output is correct
68 Correct 13 ms 460 KB Output is correct
69 Correct 5 ms 340 KB Output is correct
70 Correct 8 ms 352 KB Output is correct
71 Correct 8 ms 448 KB Output is correct
72 Correct 8 ms 476 KB Output is correct
73 Correct 10 ms 468 KB Output is correct
74 Correct 10 ms 440 KB Output is correct
75 Correct 10 ms 468 KB Output is correct
76 Correct 12 ms 476 KB Output is correct
77 Correct 14 ms 616 KB Output is correct
78 Correct 21 ms 608 KB Output is correct
79 Correct 25 ms 608 KB Output is correct
80 Correct 25 ms 608 KB Output is correct
81 Correct 29 ms 608 KB Output is correct
82 Correct 37 ms 608 KB Output is correct
83 Correct 36 ms 576 KB Output is correct
84 Correct 36 ms 608 KB Output is correct
85 Correct 14 ms 576 KB Output is correct
86 Correct 23 ms 608 KB Output is correct
87 Correct 22 ms 608 KB Output is correct
88 Correct 22 ms 576 KB Output is correct
89 Correct 28 ms 608 KB Output is correct
90 Correct 29 ms 608 KB Output is correct
91 Correct 28 ms 480 KB Output is correct
92 Correct 29 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 216 KB Output is correct
6 Correct 0 ms 216 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 1 ms 216 KB Output is correct
13 Correct 0 ms 224 KB Output is correct
14 Correct 1 ms 220 KB Output is correct
15 Correct 1 ms 220 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 0 ms 224 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 1 ms 224 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 304 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 304 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 308 KB Output is correct
26 Correct 1 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 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 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 0 ms 300 KB Output is correct
36 Correct 1 ms 312 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 304 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 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 308 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 312 KB Output is correct
65 Correct 10 ms 340 KB Output is correct
66 Correct 10 ms 476 KB Output is correct
67 Correct 11 ms 428 KB Output is correct
68 Correct 13 ms 460 KB Output is correct
69 Correct 5 ms 340 KB Output is correct
70 Correct 8 ms 352 KB Output is correct
71 Correct 8 ms 448 KB Output is correct
72 Correct 8 ms 476 KB Output is correct
73 Correct 10 ms 468 KB Output is correct
74 Correct 10 ms 440 KB Output is correct
75 Correct 10 ms 468 KB Output is correct
76 Correct 12 ms 476 KB Output is correct
77 Correct 14 ms 616 KB Output is correct
78 Correct 21 ms 608 KB Output is correct
79 Correct 25 ms 608 KB Output is correct
80 Correct 25 ms 608 KB Output is correct
81 Correct 29 ms 608 KB Output is correct
82 Correct 37 ms 608 KB Output is correct
83 Correct 36 ms 576 KB Output is correct
84 Correct 36 ms 608 KB Output is correct
85 Correct 14 ms 576 KB Output is correct
86 Correct 23 ms 608 KB Output is correct
87 Correct 22 ms 608 KB Output is correct
88 Correct 22 ms 576 KB Output is correct
89 Correct 28 ms 608 KB Output is correct
90 Correct 29 ms 608 KB Output is correct
91 Correct 28 ms 480 KB Output is correct
92 Correct 29 ms 608 KB Output is correct
93 Correct 595 ms 2648 KB Output is correct
94 Correct 259 ms 2608 KB Output is correct
95 Correct 127 ms 2636 KB Output is correct
96 Correct 738 ms 2604 KB Output is correct
97 Correct 733 ms 2516 KB Output is correct
98 Correct 580 ms 2588 KB Output is correct
99 Correct 27 ms 872 KB Output is correct
100 Correct 49 ms 868 KB Output is correct
101 Correct 66 ms 876 KB Output is correct
102 Correct 80 ms 876 KB Output is correct
103 Correct 8 ms 1364 KB Output is correct
104 Correct 12 ms 1364 KB Output is correct
105 Correct 26 ms 1364 KB Output is correct
106 Correct 94 ms 1468 KB Output is correct
107 Correct 15 ms 2540 KB Output is correct
108 Correct 68 ms 2484 KB Output is correct
109 Correct 279 ms 2516 KB Output is correct
110 Correct 614 ms 2592 KB Output is correct
111 Correct 95 ms 940 KB Output is correct
112 Correct 97 ms 876 KB Output is correct
113 Correct 107 ms 868 KB Output is correct
114 Correct 41 ms 972 KB Output is correct
115 Correct 65 ms 852 KB Output is correct
116 Correct 65 ms 868 KB Output is correct
117 Correct 64 ms 852 KB Output is correct
118 Correct 81 ms 852 KB Output is correct
119 Correct 83 ms 852 KB Output is correct
120 Correct 81 ms 852 KB Output is correct
121 Correct 81 ms 876 KB Output is correct
122 Correct 197 ms 1448 KB Output is correct
123 Correct 263 ms 1448 KB Output is correct
124 Correct 290 ms 1456 KB Output is correct
125 Correct 303 ms 1460 KB Output is correct
126 Correct 314 ms 1364 KB Output is correct
127 Correct 327 ms 1448 KB Output is correct
128 Correct 334 ms 1488 KB Output is correct
129 Correct 332 ms 1364 KB Output is correct
130 Correct 356 ms 1444 KB Output is correct
131 Correct 122 ms 1460 KB Output is correct
132 Correct 211 ms 1452 KB Output is correct
133 Correct 190 ms 1448 KB Output is correct
134 Correct 188 ms 1456 KB Output is correct
135 Correct 241 ms 1448 KB Output is correct
136 Correct 245 ms 1460 KB Output is correct
137 Correct 237 ms 1448 KB Output is correct
138 Correct 242 ms 1444 KB Output is correct
139 Correct 279 ms 1452 KB Output is correct
140 Correct 273 ms 1456 KB Output is correct
141 Correct 274 ms 1448 KB Output is correct
142 Correct 784 ms 2516 KB Output is correct
143 Correct 907 ms 2636 KB Output is correct
144 Correct 953 ms 2592 KB Output is correct
145 Correct 981 ms 2592 KB Output is correct
146 Correct 1018 ms 2604 KB Output is correct
147 Correct 1020 ms 2600 KB Output is correct
148 Correct 797 ms 2636 KB Output is correct
149 Correct 852 ms 2636 KB Output is correct
150 Correct 825 ms 2592 KB Output is correct
151 Correct 428 ms 2620 KB Output is correct
152 Correct 436 ms 2596 KB Output is correct
153 Correct 734 ms 2636 KB Output is correct
154 Correct 724 ms 2592 KB Output is correct
155 Correct 721 ms 2592 KB Output is correct
156 Correct 710 ms 2592 KB Output is correct
157 Correct 761 ms 2592 KB Output is correct
158 Correct 723 ms 2604 KB Output is correct
159 Correct 820 ms 2636 KB Output is correct
160 Correct 812 ms 2592 KB Output is correct
161 Correct 803 ms 2636 KB Output is correct
162 Correct 886 ms 2636 KB Output is correct
163 Correct 890 ms 2636 KB Output is correct
164 Correct 890 ms 2588 KB Output is correct
165 Correct 882 ms 2596 KB Output is correct
166 Correct 883 ms 2636 KB Output is correct
167 Correct 874 ms 2636 KB Output is correct