# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
404201 |
2021-05-13T23:57:15 Z |
rama_pang |
Paths (BOI18_paths) |
C++17 |
|
571 ms |
70708 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N, M, K;
cin >> N >> M >> K;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
A[i]--;
}
vector<vector<int>> adj(N);
while (M--) {
int u, v;
cin >> u >> v;
u--, v--;
adj[u].emplace_back(v);
adj[v].emplace_back(u);
}
vector<vector<long long>> dp(N, vector<long long>(1 << K));
for (int mask = (1 << K) - 1; mask >= 0; mask--) {
for (int i = 0; i < N; i++) if ((mask >> A[i]) & 1) {
dp[i][mask] += 1;
}
for (int i = 0; i < N; i++) if ((mask >> A[i]) & 1) {
for (auto j : adj[i]) if (((mask >> A[j]) & 1) ^ 1) {
dp[i][mask] += dp[j][mask | (1 << A[j])];
}
}
}
long long ans = 0;
for (int i = 0; i < N; i++) {
ans += dp[i][1 << A[i]];
}
cout << ans - N << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
7028 KB |
Output is correct |
2 |
Correct |
73 ms |
6104 KB |
Output is correct |
3 |
Correct |
403 ms |
51872 KB |
Output is correct |
4 |
Correct |
111 ms |
10564 KB |
Output is correct |
5 |
Correct |
100 ms |
9976 KB |
Output is correct |
6 |
Correct |
261 ms |
37292 KB |
Output is correct |
7 |
Correct |
376 ms |
51788 KB |
Output is correct |
8 |
Correct |
400 ms |
52564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
84 ms |
7028 KB |
Output is correct |
12 |
Correct |
73 ms |
6104 KB |
Output is correct |
13 |
Correct |
403 ms |
51872 KB |
Output is correct |
14 |
Correct |
111 ms |
10564 KB |
Output is correct |
15 |
Correct |
100 ms |
9976 KB |
Output is correct |
16 |
Correct |
261 ms |
37292 KB |
Output is correct |
17 |
Correct |
376 ms |
51788 KB |
Output is correct |
18 |
Correct |
400 ms |
52564 KB |
Output is correct |
19 |
Correct |
87 ms |
7100 KB |
Output is correct |
20 |
Correct |
72 ms |
6168 KB |
Output is correct |
21 |
Correct |
355 ms |
51900 KB |
Output is correct |
22 |
Correct |
110 ms |
10564 KB |
Output is correct |
23 |
Correct |
114 ms |
10028 KB |
Output is correct |
24 |
Correct |
274 ms |
37344 KB |
Output is correct |
25 |
Correct |
351 ms |
51912 KB |
Output is correct |
26 |
Correct |
355 ms |
52544 KB |
Output is correct |
27 |
Correct |
84 ms |
6160 KB |
Output is correct |
28 |
Correct |
110 ms |
8716 KB |
Output is correct |
29 |
Correct |
571 ms |
70688 KB |
Output is correct |
30 |
Correct |
333 ms |
38940 KB |
Output is correct |
31 |
Correct |
340 ms |
38844 KB |
Output is correct |
32 |
Correct |
543 ms |
70708 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
308 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
316 KB |
Output is correct |
38 |
Correct |
1 ms |
332 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
1 ms |
332 KB |
Output is correct |
41 |
Correct |
1 ms |
316 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
40 ms |
2200 KB |
Output is correct |
3 |
Correct |
24 ms |
2188 KB |
Output is correct |
4 |
Correct |
99 ms |
17480 KB |
Output is correct |
5 |
Correct |
72 ms |
18044 KB |
Output is correct |
6 |
Correct |
233 ms |
36036 KB |
Output is correct |
7 |
Correct |
30 ms |
2132 KB |
Output is correct |
8 |
Correct |
142 ms |
23620 KB |
Output is correct |
9 |
Correct |
119 ms |
24484 KB |
Output is correct |
10 |
Correct |
129 ms |
24244 KB |
Output is correct |
11 |
Correct |
141 ms |
19232 KB |
Output is correct |
12 |
Correct |
136 ms |
28044 KB |
Output is correct |
13 |
Correct |
115 ms |
19288 KB |
Output is correct |
14 |
Correct |
226 ms |
36144 KB |
Output is correct |
15 |
Correct |
238 ms |
36164 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
332 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 |
316 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
316 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |