# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
510032 |
2022-01-14T14:23:57 Z |
haxorman |
Paths (BOI18_paths) |
C++14 |
|
420 ms |
112356 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mxN = 3e5 + 7;
const int mxK = 39;
int n, m, k, color[mxN], dp[mxN][mxK];
vector<int> graph[mxN];
void dfs(int u, int mask, int cnt) {
if (dp[u][mask]) {
return;
}
if (cnt > 1) {
dp[u][mask] = 1;
}
for (auto v : graph[u]) {
if (!(mask & (1 << color[v]))) {
dfs(v, mask | (1 << color[v]), cnt + 1);
dp[u][mask] += dp[v][mask | (1 << color[v])];
}
}
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m >> k;
for (int u = 1; u <= n; ++u) {
cin >> color[u];
color[u]--;
}
for (int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
graph[u].push_back(v);
graph[v].push_back(u);
}
int ans = 0;
for (int i = 1; i <= n; ++i) {
dfs(i, (1 << color[i]), 1);
ans += dp[i][(1 << color[i])];
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7372 KB |
Output is correct |
2 |
Correct |
4 ms |
7372 KB |
Output is correct |
3 |
Correct |
4 ms |
7372 KB |
Output is correct |
4 |
Correct |
4 ms |
7388 KB |
Output is correct |
5 |
Correct |
4 ms |
7364 KB |
Output is correct |
6 |
Correct |
4 ms |
7296 KB |
Output is correct |
7 |
Correct |
4 ms |
7360 KB |
Output is correct |
8 |
Correct |
4 ms |
7372 KB |
Output is correct |
9 |
Correct |
4 ms |
7372 KB |
Output is correct |
10 |
Correct |
4 ms |
7364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
16132 KB |
Output is correct |
2 |
Correct |
59 ms |
14748 KB |
Output is correct |
3 |
Correct |
372 ms |
111776 KB |
Output is correct |
4 |
Correct |
101 ms |
24960 KB |
Output is correct |
5 |
Correct |
90 ms |
15704 KB |
Output is correct |
6 |
Correct |
215 ms |
78864 KB |
Output is correct |
7 |
Correct |
350 ms |
111852 KB |
Output is correct |
8 |
Correct |
326 ms |
112356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7372 KB |
Output is correct |
2 |
Correct |
4 ms |
7372 KB |
Output is correct |
3 |
Correct |
4 ms |
7372 KB |
Output is correct |
4 |
Correct |
4 ms |
7388 KB |
Output is correct |
5 |
Correct |
4 ms |
7364 KB |
Output is correct |
6 |
Correct |
4 ms |
7296 KB |
Output is correct |
7 |
Correct |
4 ms |
7360 KB |
Output is correct |
8 |
Correct |
4 ms |
7372 KB |
Output is correct |
9 |
Correct |
4 ms |
7372 KB |
Output is correct |
10 |
Correct |
4 ms |
7364 KB |
Output is correct |
11 |
Correct |
73 ms |
16132 KB |
Output is correct |
12 |
Correct |
59 ms |
14748 KB |
Output is correct |
13 |
Correct |
372 ms |
111776 KB |
Output is correct |
14 |
Correct |
101 ms |
24960 KB |
Output is correct |
15 |
Correct |
90 ms |
15704 KB |
Output is correct |
16 |
Correct |
215 ms |
78864 KB |
Output is correct |
17 |
Correct |
350 ms |
111852 KB |
Output is correct |
18 |
Correct |
326 ms |
112356 KB |
Output is correct |
19 |
Correct |
70 ms |
16080 KB |
Output is correct |
20 |
Correct |
57 ms |
14740 KB |
Output is correct |
21 |
Correct |
351 ms |
111804 KB |
Output is correct |
22 |
Correct |
104 ms |
24900 KB |
Output is correct |
23 |
Correct |
89 ms |
15812 KB |
Output is correct |
24 |
Correct |
223 ms |
78836 KB |
Output is correct |
25 |
Correct |
327 ms |
111788 KB |
Output is correct |
26 |
Correct |
323 ms |
112324 KB |
Output is correct |
27 |
Correct |
66 ms |
14768 KB |
Output is correct |
28 |
Correct |
94 ms |
18520 KB |
Output is correct |
29 |
Correct |
420 ms |
111920 KB |
Output is correct |
30 |
Correct |
323 ms |
63052 KB |
Output is correct |
31 |
Correct |
308 ms |
63288 KB |
Output is correct |
32 |
Correct |
383 ms |
111976 KB |
Output is correct |
33 |
Correct |
4 ms |
7372 KB |
Output is correct |
34 |
Correct |
4 ms |
7368 KB |
Output is correct |
35 |
Correct |
4 ms |
7372 KB |
Output is correct |
36 |
Correct |
4 ms |
7372 KB |
Output is correct |
37 |
Correct |
4 ms |
7372 KB |
Output is correct |
38 |
Correct |
4 ms |
7368 KB |
Output is correct |
39 |
Correct |
4 ms |
7368 KB |
Output is correct |
40 |
Correct |
4 ms |
7372 KB |
Output is correct |
41 |
Correct |
4 ms |
7372 KB |
Output is correct |
42 |
Correct |
4 ms |
7372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7372 KB |
Output is correct |
2 |
Correct |
33 ms |
9692 KB |
Output is correct |
3 |
Correct |
22 ms |
9708 KB |
Output is correct |
4 |
Correct |
87 ms |
42148 KB |
Output is correct |
5 |
Correct |
61 ms |
42552 KB |
Output is correct |
6 |
Correct |
109 ms |
42180 KB |
Output is correct |
7 |
Correct |
28 ms |
9828 KB |
Output is correct |
8 |
Correct |
101 ms |
42220 KB |
Output is correct |
9 |
Correct |
73 ms |
42588 KB |
Output is correct |
10 |
Correct |
99 ms |
42400 KB |
Output is correct |
11 |
Correct |
87 ms |
25676 KB |
Output is correct |
12 |
Correct |
68 ms |
33972 KB |
Output is correct |
13 |
Correct |
85 ms |
25748 KB |
Output is correct |
14 |
Correct |
126 ms |
42068 KB |
Output is correct |
15 |
Correct |
96 ms |
42280 KB |
Output is correct |
16 |
Correct |
3 ms |
7372 KB |
Output is correct |
17 |
Correct |
4 ms |
7372 KB |
Output is correct |
18 |
Correct |
4 ms |
7372 KB |
Output is correct |
19 |
Correct |
4 ms |
7372 KB |
Output is correct |
20 |
Correct |
4 ms |
7304 KB |
Output is correct |
21 |
Correct |
4 ms |
7372 KB |
Output is correct |
22 |
Correct |
3 ms |
7372 KB |
Output is correct |
23 |
Correct |
4 ms |
7372 KB |
Output is correct |
24 |
Correct |
4 ms |
7372 KB |
Output is correct |
25 |
Correct |
3 ms |
7260 KB |
Output is correct |