# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
869373 |
2023-11-04T08:40:46 Z |
12345678 |
Paths (BOI18_paths) |
C++17 |
|
362 ms |
98388 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=3e5+5;
ll n, m, k, u, v, c[nx], dp[nx][32], ans;
vector<int> d[nx];
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m>>k;
for (int i=1; i<=n; i++) cin>>c[i], c[i]--;
for (int i=0; i<m; i++) cin>>u>>v, d[u].push_back(v), d[v].push_back(u);
for (int i=1; i<(1<<k); i++)
{
for (int j=1; j<=n; j++)
{
if (!(i&(1<<c[j]))) continue;
if (__builtin_popcount(i)==1) dp[j][i]++;
for (auto v:d[j]) dp[j][i]+=dp[v][i-(1<<c[j])];
ans+=dp[j][i];
}
}
cout<<ans-n;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10844 KB |
Output is correct |
2 |
Correct |
3 ms |
10752 KB |
Output is correct |
3 |
Correct |
2 ms |
10844 KB |
Output is correct |
4 |
Correct |
2 ms |
10844 KB |
Output is correct |
5 |
Correct |
2 ms |
10844 KB |
Output is correct |
6 |
Correct |
2 ms |
10844 KB |
Output is correct |
7 |
Correct |
3 ms |
11096 KB |
Output is correct |
8 |
Correct |
2 ms |
10844 KB |
Output is correct |
9 |
Correct |
2 ms |
10844 KB |
Output is correct |
10 |
Correct |
2 ms |
10844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
14500 KB |
Output is correct |
2 |
Correct |
42 ms |
14416 KB |
Output is correct |
3 |
Correct |
275 ms |
97648 KB |
Output is correct |
4 |
Correct |
74 ms |
26824 KB |
Output is correct |
5 |
Correct |
63 ms |
26904 KB |
Output is correct |
6 |
Correct |
175 ms |
72668 KB |
Output is correct |
7 |
Correct |
296 ms |
97652 KB |
Output is correct |
8 |
Correct |
241 ms |
98384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10844 KB |
Output is correct |
2 |
Correct |
3 ms |
10752 KB |
Output is correct |
3 |
Correct |
2 ms |
10844 KB |
Output is correct |
4 |
Correct |
2 ms |
10844 KB |
Output is correct |
5 |
Correct |
2 ms |
10844 KB |
Output is correct |
6 |
Correct |
2 ms |
10844 KB |
Output is correct |
7 |
Correct |
3 ms |
11096 KB |
Output is correct |
8 |
Correct |
2 ms |
10844 KB |
Output is correct |
9 |
Correct |
2 ms |
10844 KB |
Output is correct |
10 |
Correct |
2 ms |
10844 KB |
Output is correct |
11 |
Correct |
45 ms |
14500 KB |
Output is correct |
12 |
Correct |
42 ms |
14416 KB |
Output is correct |
13 |
Correct |
275 ms |
97648 KB |
Output is correct |
14 |
Correct |
74 ms |
26824 KB |
Output is correct |
15 |
Correct |
63 ms |
26904 KB |
Output is correct |
16 |
Correct |
175 ms |
72668 KB |
Output is correct |
17 |
Correct |
296 ms |
97652 KB |
Output is correct |
18 |
Correct |
241 ms |
98384 KB |
Output is correct |
19 |
Correct |
44 ms |
17228 KB |
Output is correct |
20 |
Correct |
45 ms |
16640 KB |
Output is correct |
21 |
Correct |
261 ms |
97880 KB |
Output is correct |
22 |
Correct |
64 ms |
26708 KB |
Output is correct |
23 |
Correct |
60 ms |
26888 KB |
Output is correct |
24 |
Correct |
162 ms |
72648 KB |
Output is correct |
25 |
Correct |
269 ms |
97812 KB |
Output is correct |
26 |
Correct |
258 ms |
98388 KB |
Output is correct |
27 |
Correct |
37 ms |
16732 KB |
Output is correct |
28 |
Correct |
51 ms |
18804 KB |
Output is correct |
29 |
Correct |
356 ms |
97620 KB |
Output is correct |
30 |
Correct |
206 ms |
58820 KB |
Output is correct |
31 |
Correct |
239 ms |
58848 KB |
Output is correct |
32 |
Correct |
362 ms |
97772 KB |
Output is correct |
33 |
Correct |
2 ms |
10840 KB |
Output is correct |
34 |
Correct |
2 ms |
10840 KB |
Output is correct |
35 |
Correct |
2 ms |
10844 KB |
Output is correct |
36 |
Correct |
3 ms |
10896 KB |
Output is correct |
37 |
Correct |
2 ms |
10844 KB |
Output is correct |
38 |
Correct |
2 ms |
10844 KB |
Output is correct |
39 |
Correct |
2 ms |
10844 KB |
Output is correct |
40 |
Correct |
2 ms |
10844 KB |
Output is correct |
41 |
Correct |
2 ms |
10844 KB |
Output is correct |
42 |
Correct |
2 ms |
10872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10844 KB |
Output is correct |
2 |
Correct |
15 ms |
11996 KB |
Output is correct |
3 |
Correct |
13 ms |
12708 KB |
Output is correct |
4 |
Correct |
68 ms |
40532 KB |
Output is correct |
5 |
Correct |
50 ms |
41416 KB |
Output is correct |
6 |
Correct |
166 ms |
40788 KB |
Output is correct |
7 |
Correct |
13 ms |
12632 KB |
Output is correct |
8 |
Correct |
90 ms |
40532 KB |
Output is correct |
9 |
Correct |
67 ms |
41428 KB |
Output is correct |
10 |
Correct |
92 ms |
41164 KB |
Output is correct |
11 |
Correct |
66 ms |
27084 KB |
Output is correct |
12 |
Correct |
80 ms |
34244 KB |
Output is correct |
13 |
Correct |
55 ms |
27180 KB |
Output is correct |
14 |
Correct |
143 ms |
40784 KB |
Output is correct |
15 |
Correct |
165 ms |
40876 KB |
Output is correct |
16 |
Correct |
2 ms |
10844 KB |
Output is correct |
17 |
Correct |
2 ms |
10844 KB |
Output is correct |
18 |
Correct |
2 ms |
10844 KB |
Output is correct |
19 |
Correct |
2 ms |
10840 KB |
Output is correct |
20 |
Correct |
2 ms |
11096 KB |
Output is correct |
21 |
Correct |
2 ms |
10844 KB |
Output is correct |
22 |
Correct |
2 ms |
10844 KB |
Output is correct |
23 |
Correct |
2 ms |
10844 KB |
Output is correct |
24 |
Correct |
2 ms |
10844 KB |
Output is correct |
25 |
Correct |
2 ms |
10844 KB |
Output is correct |