Submission #441145

# Submission time Handle Problem Language Result Execution time Memory
441145 2021-07-04T11:45:02 Z hhhhaura Amusement Park (CEOI19_amusementpark) C++14
100 / 100
2003 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]);
				if(dp[i] < 0) dp[i] += MOD;
				if(dp[i] >= MOD) dp[i] -= 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 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 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 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 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 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 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 0 ms 204 KB Output is correct
23 Correct 0 ms 204 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 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 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 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 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 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 332 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 0 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 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 1 ms 204 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 204 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 332 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 204 KB Output is correct
64 Correct 1 ms 344 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 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 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 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 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 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 332 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 0 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 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 1 ms 204 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 204 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 332 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 204 KB Output is correct
64 Correct 1 ms 344 KB Output is correct
65 Correct 12 ms 732 KB Output is correct
66 Correct 13 ms 728 KB Output is correct
67 Correct 10 ms 728 KB Output is correct
68 Correct 12 ms 724 KB Output is correct
69 Correct 16 ms 600 KB Output is correct
70 Correct 13 ms 736 KB Output is correct
71 Correct 13 ms 592 KB Output is correct
72 Correct 14 ms 732 KB Output is correct
73 Correct 13 ms 736 KB Output is correct
74 Correct 10 ms 588 KB Output is correct
75 Correct 11 ms 716 KB Output is correct
76 Correct 11 ms 716 KB Output is correct
77 Correct 34 ms 972 KB Output is correct
78 Correct 29 ms 1100 KB Output is correct
79 Correct 28 ms 1100 KB Output is correct
80 Correct 26 ms 1100 KB Output is correct
81 Correct 26 ms 1100 KB Output is correct
82 Correct 25 ms 1104 KB Output is correct
83 Correct 24 ms 1104 KB Output is correct
84 Correct 24 ms 1108 KB Output is correct
85 Correct 47 ms 972 KB Output is correct
86 Correct 35 ms 972 KB Output is correct
87 Correct 43 ms 1100 KB Output is correct
88 Correct 38 ms 1100 KB Output is correct
89 Correct 74 ms 1100 KB Output is correct
90 Correct 30 ms 1080 KB Output is correct
91 Correct 31 ms 1100 KB Output is correct
92 Correct 35 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 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 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 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 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 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 332 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 0 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 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 1 ms 204 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 204 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 332 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 204 KB Output is correct
64 Correct 1 ms 344 KB Output is correct
65 Correct 12 ms 732 KB Output is correct
66 Correct 13 ms 728 KB Output is correct
67 Correct 10 ms 728 KB Output is correct
68 Correct 12 ms 724 KB Output is correct
69 Correct 16 ms 600 KB Output is correct
70 Correct 13 ms 736 KB Output is correct
71 Correct 13 ms 592 KB Output is correct
72 Correct 14 ms 732 KB Output is correct
73 Correct 13 ms 736 KB Output is correct
74 Correct 10 ms 588 KB Output is correct
75 Correct 11 ms 716 KB Output is correct
76 Correct 11 ms 716 KB Output is correct
77 Correct 34 ms 972 KB Output is correct
78 Correct 29 ms 1100 KB Output is correct
79 Correct 28 ms 1100 KB Output is correct
80 Correct 26 ms 1100 KB Output is correct
81 Correct 26 ms 1100 KB Output is correct
82 Correct 25 ms 1104 KB Output is correct
83 Correct 24 ms 1104 KB Output is correct
84 Correct 24 ms 1108 KB Output is correct
85 Correct 47 ms 972 KB Output is correct
86 Correct 35 ms 972 KB Output is correct
87 Correct 43 ms 1100 KB Output is correct
88 Correct 38 ms 1100 KB Output is correct
89 Correct 74 ms 1100 KB Output is correct
90 Correct 30 ms 1080 KB Output is correct
91 Correct 31 ms 1100 KB Output is correct
92 Correct 35 ms 1100 KB Output is correct
93 Correct 1088 ms 6476 KB Output is correct
94 Correct 1096 ms 6476 KB Output is correct
95 Correct 1108 ms 6476 KB Output is correct
96 Correct 918 ms 6476 KB Output is correct
97 Correct 872 ms 6476 KB Output is correct
98 Correct 919 ms 6596 KB Output is correct
99 Correct 105 ms 1868 KB Output is correct
100 Correct 92 ms 1868 KB Output is correct
101 Correct 91 ms 1868 KB Output is correct
102 Correct 70 ms 1868 KB Output is correct
103 Correct 634 ms 3404 KB Output is correct
104 Correct 396 ms 3404 KB Output is correct
105 Correct 315 ms 3404 KB Output is correct
106 Correct 259 ms 3404 KB Output is correct
107 Correct 2003 ms 6476 KB Output is correct
108 Correct 941 ms 6496 KB Output is correct
109 Correct 754 ms 6476 KB Output is correct
110 Correct 623 ms 6476 KB Output is correct
111 Correct 66 ms 1868 KB Output is correct
112 Correct 71 ms 1868 KB Output is correct
113 Correct 61 ms 1868 KB Output is correct
114 Correct 156 ms 1852 KB Output is correct
115 Correct 112 ms 1868 KB Output is correct
116 Correct 120 ms 1848 KB Output is correct
117 Correct 116 ms 1848 KB Output is correct
118 Correct 94 ms 1868 KB Output is correct
119 Correct 89 ms 1868 KB Output is correct
120 Correct 94 ms 1852 KB Output is correct
121 Correct 90 ms 1868 KB Output is correct
122 Correct 234 ms 3404 KB Output is correct
123 Correct 217 ms 3404 KB Output is correct
124 Correct 179 ms 3404 KB Output is correct
125 Correct 183 ms 3404 KB Output is correct
126 Correct 182 ms 3404 KB Output is correct
127 Correct 180 ms 3404 KB Output is correct
128 Correct 161 ms 3404 KB Output is correct
129 Correct 156 ms 3404 KB Output is correct
130 Correct 162 ms 3404 KB Output is correct
131 Correct 451 ms 3404 KB Output is correct
132 Correct 381 ms 3404 KB Output is correct
133 Correct 339 ms 3404 KB Output is correct
134 Correct 340 ms 3404 KB Output is correct
135 Correct 276 ms 3404 KB Output is correct
136 Correct 261 ms 3404 KB Output is correct
137 Correct 266 ms 3404 KB Output is correct
138 Correct 269 ms 3404 KB Output is correct
139 Correct 235 ms 3404 KB Output is correct
140 Correct 256 ms 3404 KB Output is correct
141 Correct 228 ms 3404 KB Output is correct
142 Correct 557 ms 6476 KB Output is correct
143 Correct 508 ms 6492 KB Output is correct
144 Correct 488 ms 6596 KB Output is correct
145 Correct 471 ms 6596 KB Output is correct
146 Correct 468 ms 6476 KB Output is correct
147 Correct 443 ms 6476 KB Output is correct
148 Correct 558 ms 6476 KB Output is correct
149 Correct 531 ms 6476 KB Output is correct
150 Correct 537 ms 6596 KB Output is correct
151 Correct 673 ms 6476 KB Output is correct
152 Correct 650 ms 6484 KB Output is correct
153 Correct 907 ms 6476 KB Output is correct
154 Correct 884 ms 6596 KB Output is correct
155 Correct 850 ms 6596 KB Output is correct
156 Correct 834 ms 6596 KB Output is correct
157 Correct 812 ms 6596 KB Output is correct
158 Correct 808 ms 6476 KB Output is correct
159 Correct 749 ms 6484 KB Output is correct
160 Correct 670 ms 6476 KB Output is correct
161 Correct 696 ms 6476 KB Output is correct
162 Correct 689 ms 6476 KB Output is correct
163 Correct 616 ms 6596 KB Output is correct
164 Correct 590 ms 6596 KB Output is correct
165 Correct 591 ms 6476 KB Output is correct
166 Correct 590 ms 6488 KB Output is correct
167 Correct 605 ms 6476 KB Output is correct