Submission #441143

# Submission time Handle Problem Language Result Execution time Memory
441143 2021-07-04T11:43:39 Z hhhhaura Amusement Park (CEOI19_amusementpark) C++14
100 / 100
2703 ms 6596 KB
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)

#define rep(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))

#define INF 1000000000000000000
#define MOD 998244353
#define eps (1e-9)

using namespace std;

#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

#ifdef wiwihorz
#define print(a...) kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else
#define print(...) 0
#define vprint(...) 0
#endif
namespace solver {
	int n, m, inv2 = 499122177;
	vector<int> dp, ok, cnt;
	vector<pii> es;
	void init_(int _n, int _m) {
		n = _n, m = _m;
		es.clear();
		dp.assign(1 << n, 0);
		ok.assign(1 << n, 0);
		cnt.assign(1 << n, 0);
	}
	int solve() {
		rep(i, 1, (1 << n) - 1) {
			bool yes = 0;
			for(auto j : es) {
				yes |= (((i >> (j.first - 1)) & 1) 
					&& ((i >> (j.second - 1)) & 1));
			}
			cnt[i] = __builtin_popcount(i);
			ok[i] = !yes; 
		}
		dp[0] = 1;
		rep(i, 1, (1 << n) - 1) {
			for(int j = i; j > 0; j = (j - 1) & i) {
				if(!ok[j]) continue;
				dp[i] = (dp[i] + ((cnt[j] & 1) ? 1 : -1) * dp[i ^ j]) % MOD;
			}
		}
		int ans = m * inv2 % MOD * dp[(1 << n) - 1] % MOD;
		return (ans + MOD) % MOD;
	}
};
using namespace solver;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n, m; cin >> n >> m;
	init_(n, m);
	rep(i, 1, m) {
		int a, b; cin >> a >> b;
		es.push_back({a, b});
	}
	cout << solve() << "\n";
	return 0;
}

Compilation message

amusementpark.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
amusementpark.cpp:24:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
amusementpark.cpp:24:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 312 KB Output is correct
31 Correct 1 ms 312 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 316 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 308 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 316 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 1 ms 204 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 312 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 312 KB Output is correct
31 Correct 1 ms 312 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 316 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 308 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 316 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 1 ms 204 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 312 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 1 ms 332 KB Output is correct
65 Correct 12 ms 720 KB Output is correct
66 Correct 12 ms 716 KB Output is correct
67 Correct 12 ms 728 KB Output is correct
68 Correct 11 ms 724 KB Output is correct
69 Correct 23 ms 692 KB Output is correct
70 Correct 16 ms 716 KB Output is correct
71 Correct 19 ms 716 KB Output is correct
72 Correct 19 ms 716 KB Output is correct
73 Correct 14 ms 728 KB Output is correct
74 Correct 13 ms 716 KB Output is correct
75 Correct 15 ms 724 KB Output is correct
76 Correct 16 ms 716 KB Output is correct
77 Correct 36 ms 1088 KB Output is correct
78 Correct 33 ms 1100 KB Output is correct
79 Correct 32 ms 1100 KB Output is correct
80 Correct 30 ms 1100 KB Output is correct
81 Correct 30 ms 1104 KB Output is correct
82 Correct 28 ms 1100 KB Output is correct
83 Correct 28 ms 1108 KB Output is correct
84 Correct 27 ms 1100 KB Output is correct
85 Correct 68 ms 972 KB Output is correct
86 Correct 46 ms 972 KB Output is correct
87 Correct 52 ms 1076 KB Output is correct
88 Correct 55 ms 972 KB Output is correct
89 Correct 37 ms 1100 KB Output is correct
90 Correct 39 ms 1104 KB Output is correct
91 Correct 42 ms 1084 KB Output is correct
92 Correct 46 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 312 KB Output is correct
31 Correct 1 ms 312 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 316 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 308 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 308 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 316 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 1 ms 204 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 312 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 1 ms 332 KB Output is correct
65 Correct 12 ms 720 KB Output is correct
66 Correct 12 ms 716 KB Output is correct
67 Correct 12 ms 728 KB Output is correct
68 Correct 11 ms 724 KB Output is correct
69 Correct 23 ms 692 KB Output is correct
70 Correct 16 ms 716 KB Output is correct
71 Correct 19 ms 716 KB Output is correct
72 Correct 19 ms 716 KB Output is correct
73 Correct 14 ms 728 KB Output is correct
74 Correct 13 ms 716 KB Output is correct
75 Correct 15 ms 724 KB Output is correct
76 Correct 16 ms 716 KB Output is correct
77 Correct 36 ms 1088 KB Output is correct
78 Correct 33 ms 1100 KB Output is correct
79 Correct 32 ms 1100 KB Output is correct
80 Correct 30 ms 1100 KB Output is correct
81 Correct 30 ms 1104 KB Output is correct
82 Correct 28 ms 1100 KB Output is correct
83 Correct 28 ms 1108 KB Output is correct
84 Correct 27 ms 1100 KB Output is correct
85 Correct 68 ms 972 KB Output is correct
86 Correct 46 ms 972 KB Output is correct
87 Correct 52 ms 1076 KB Output is correct
88 Correct 55 ms 972 KB Output is correct
89 Correct 37 ms 1100 KB Output is correct
90 Correct 39 ms 1104 KB Output is correct
91 Correct 42 ms 1084 KB Output is correct
92 Correct 46 ms 1100 KB Output is correct
93 Correct 1314 ms 6484 KB Output is correct
94 Correct 1323 ms 6476 KB Output is correct
95 Correct 1322 ms 6576 KB Output is correct
96 Correct 1045 ms 6476 KB Output is correct
97 Correct 1020 ms 6596 KB Output is correct
98 Correct 1119 ms 6484 KB Output is correct
99 Correct 111 ms 1868 KB Output is correct
100 Correct 97 ms 1868 KB Output is correct
101 Correct 91 ms 1868 KB Output is correct
102 Correct 85 ms 1868 KB Output is correct
103 Correct 889 ms 3404 KB Output is correct
104 Correct 512 ms 3404 KB Output is correct
105 Correct 378 ms 3404 KB Output is correct
106 Correct 296 ms 3404 KB Output is correct
107 Correct 2703 ms 6476 KB Output is correct
108 Correct 1132 ms 6476 KB Output is correct
109 Correct 865 ms 6476 KB Output is correct
110 Correct 766 ms 6476 KB Output is correct
111 Correct 82 ms 1868 KB Output is correct
112 Correct 78 ms 1868 KB Output is correct
113 Correct 77 ms 1868 KB Output is correct
114 Correct 202 ms 1860 KB Output is correct
115 Correct 139 ms 1868 KB Output is correct
116 Correct 153 ms 1848 KB Output is correct
117 Correct 169 ms 1868 KB Output is correct
118 Correct 107 ms 1868 KB Output is correct
119 Correct 115 ms 1868 KB Output is correct
120 Correct 126 ms 1868 KB Output is correct
121 Correct 131 ms 1868 KB Output is correct
122 Correct 269 ms 3416 KB Output is correct
123 Correct 244 ms 3524 KB Output is correct
124 Correct 227 ms 3404 KB Output is correct
125 Correct 227 ms 3524 KB Output is correct
126 Correct 217 ms 3404 KB Output is correct
127 Correct 211 ms 3404 KB Output is correct
128 Correct 213 ms 3404 KB Output is correct
129 Correct 206 ms 3412 KB Output is correct
130 Correct 208 ms 3404 KB Output is correct
131 Correct 598 ms 3404 KB Output is correct
132 Correct 422 ms 3404 KB Output is correct
133 Correct 470 ms 3404 KB Output is correct
134 Correct 502 ms 3404 KB Output is correct
135 Correct 331 ms 3524 KB Output is correct
136 Correct 348 ms 3404 KB Output is correct
137 Correct 376 ms 3404 KB Output is correct
138 Correct 399 ms 3404 KB Output is correct
139 Correct 286 ms 3404 KB Output is correct
140 Correct 334 ms 3404 KB Output is correct
141 Correct 327 ms 3404 KB Output is correct
142 Correct 694 ms 6476 KB Output is correct
143 Correct 671 ms 6596 KB Output is correct
144 Correct 652 ms 6484 KB Output is correct
145 Correct 631 ms 6492 KB Output is correct
146 Correct 632 ms 6588 KB Output is correct
147 Correct 610 ms 6480 KB Output is correct
148 Correct 718 ms 6476 KB Output is correct
149 Correct 697 ms 6596 KB Output is correct
150 Correct 693 ms 6476 KB Output is correct
151 Correct 877 ms 6476 KB Output is correct
152 Correct 849 ms 6476 KB Output is correct
153 Correct 1050 ms 6476 KB Output is correct
154 Correct 1065 ms 6480 KB Output is correct
155 Correct 1176 ms 6476 KB Output is correct
156 Correct 1220 ms 6476 KB Output is correct
157 Correct 1058 ms 6476 KB Output is correct
158 Correct 1149 ms 6488 KB Output is correct
159 Correct 918 ms 6596 KB Output is correct
160 Correct 904 ms 6476 KB Output is correct
161 Correct 1008 ms 6596 KB Output is correct
162 Correct 835 ms 6476 KB Output is correct
163 Correct 817 ms 6476 KB Output is correct
164 Correct 787 ms 6596 KB Output is correct
165 Correct 814 ms 6492 KB Output is correct
166 Correct 847 ms 6476 KB Output is correct
167 Correct 863 ms 6596 KB Output is correct