# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
513742 |
2022-01-17T13:31:10 Z |
ahmeteren |
Paths (BOI18_paths) |
C++17 |
|
447 ms |
98332 KB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 3e5 + 5;
ll dp[N][(1 << 5)], c[N];
vector<int> vec[N];
ll dfs(int node, int mask)
{
if((mask & (1 << c[node])) == 0)
return 0;
if(mask == (1 << c[node]))
return 1;
if(dp[node][mask] != -1)
return dp[node][mask];
dp[node][mask] = 0;
for(auto to : vec[node])
{
dp[node][mask] += dfs(to, mask ^ (1 << c[node]));
}
return dp[node][mask];
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// #endif
int n, m, k;
cin >> n >> m >> k;
for(int i = 1; i <= n; i++)
{
cin >> c[i];
c[i]--;
}
for(int i = 1; i <= m; i++)
{
int u, v;
cin >> u >> v;
vec[u].push_back(v);
vec[v].push_back(u);
}
memset(dp, -1, sizeof(dp));
ll cevap = 0;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j < (1 << k); j++)
{
cevap += dfs(i, j);
}
}
cout << cevap - n << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
82492 KB |
Output is correct |
2 |
Correct |
36 ms |
82496 KB |
Output is correct |
3 |
Correct |
30 ms |
82444 KB |
Output is correct |
4 |
Correct |
31 ms |
82456 KB |
Output is correct |
5 |
Correct |
32 ms |
82492 KB |
Output is correct |
6 |
Correct |
31 ms |
82508 KB |
Output is correct |
7 |
Correct |
32 ms |
82500 KB |
Output is correct |
8 |
Correct |
32 ms |
82508 KB |
Output is correct |
9 |
Correct |
31 ms |
82512 KB |
Output is correct |
10 |
Correct |
32 ms |
82440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
111 ms |
88984 KB |
Output is correct |
2 |
Correct |
88 ms |
88328 KB |
Output is correct |
3 |
Correct |
313 ms |
97684 KB |
Output is correct |
4 |
Correct |
128 ms |
90440 KB |
Output is correct |
5 |
Correct |
145 ms |
90512 KB |
Output is correct |
6 |
Correct |
253 ms |
95168 KB |
Output is correct |
7 |
Correct |
327 ms |
97612 KB |
Output is correct |
8 |
Correct |
376 ms |
98332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
82492 KB |
Output is correct |
2 |
Correct |
36 ms |
82496 KB |
Output is correct |
3 |
Correct |
30 ms |
82444 KB |
Output is correct |
4 |
Correct |
31 ms |
82456 KB |
Output is correct |
5 |
Correct |
32 ms |
82492 KB |
Output is correct |
6 |
Correct |
31 ms |
82508 KB |
Output is correct |
7 |
Correct |
32 ms |
82500 KB |
Output is correct |
8 |
Correct |
32 ms |
82508 KB |
Output is correct |
9 |
Correct |
31 ms |
82512 KB |
Output is correct |
10 |
Correct |
32 ms |
82440 KB |
Output is correct |
11 |
Correct |
111 ms |
88984 KB |
Output is correct |
12 |
Correct |
88 ms |
88328 KB |
Output is correct |
13 |
Correct |
313 ms |
97684 KB |
Output is correct |
14 |
Correct |
128 ms |
90440 KB |
Output is correct |
15 |
Correct |
145 ms |
90512 KB |
Output is correct |
16 |
Correct |
253 ms |
95168 KB |
Output is correct |
17 |
Correct |
327 ms |
97612 KB |
Output is correct |
18 |
Correct |
376 ms |
98332 KB |
Output is correct |
19 |
Correct |
101 ms |
88908 KB |
Output is correct |
20 |
Correct |
89 ms |
88292 KB |
Output is correct |
21 |
Correct |
352 ms |
97660 KB |
Output is correct |
22 |
Correct |
122 ms |
90432 KB |
Output is correct |
23 |
Correct |
110 ms |
90416 KB |
Output is correct |
24 |
Correct |
209 ms |
95244 KB |
Output is correct |
25 |
Correct |
339 ms |
97600 KB |
Output is correct |
26 |
Correct |
297 ms |
98244 KB |
Output is correct |
27 |
Correct |
111 ms |
88368 KB |
Output is correct |
28 |
Correct |
139 ms |
89708 KB |
Output is correct |
29 |
Correct |
447 ms |
97684 KB |
Output is correct |
30 |
Correct |
344 ms |
93428 KB |
Output is correct |
31 |
Correct |
379 ms |
93496 KB |
Output is correct |
32 |
Correct |
403 ms |
97624 KB |
Output is correct |
33 |
Correct |
32 ms |
82496 KB |
Output is correct |
34 |
Correct |
31 ms |
82440 KB |
Output is correct |
35 |
Correct |
30 ms |
82484 KB |
Output is correct |
36 |
Correct |
38 ms |
82492 KB |
Output is correct |
37 |
Correct |
37 ms |
82476 KB |
Output is correct |
38 |
Correct |
30 ms |
82472 KB |
Output is correct |
39 |
Correct |
42 ms |
82492 KB |
Output is correct |
40 |
Correct |
35 ms |
82488 KB |
Output is correct |
41 |
Correct |
35 ms |
82488 KB |
Output is correct |
42 |
Correct |
34 ms |
82488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
82500 KB |
Output is correct |
2 |
Correct |
75 ms |
84368 KB |
Output is correct |
3 |
Correct |
77 ms |
84308 KB |
Output is correct |
4 |
Correct |
109 ms |
87412 KB |
Output is correct |
5 |
Correct |
96 ms |
88068 KB |
Output is correct |
6 |
Correct |
188 ms |
87488 KB |
Output is correct |
7 |
Correct |
88 ms |
84320 KB |
Output is correct |
8 |
Correct |
127 ms |
87412 KB |
Output is correct |
9 |
Correct |
100 ms |
88048 KB |
Output is correct |
10 |
Correct |
113 ms |
87996 KB |
Output is correct |
11 |
Correct |
141 ms |
85756 KB |
Output is correct |
12 |
Correct |
131 ms |
87140 KB |
Output is correct |
13 |
Correct |
135 ms |
85960 KB |
Output is correct |
14 |
Correct |
158 ms |
87356 KB |
Output is correct |
15 |
Correct |
175 ms |
87508 KB |
Output is correct |
16 |
Correct |
36 ms |
82384 KB |
Output is correct |
17 |
Correct |
35 ms |
82492 KB |
Output is correct |
18 |
Correct |
35 ms |
82408 KB |
Output is correct |
19 |
Correct |
35 ms |
82476 KB |
Output is correct |
20 |
Correct |
38 ms |
82488 KB |
Output is correct |
21 |
Correct |
40 ms |
82492 KB |
Output is correct |
22 |
Correct |
36 ms |
82508 KB |
Output is correct |
23 |
Correct |
36 ms |
82504 KB |
Output is correct |
24 |
Correct |
35 ms |
82412 KB |
Output is correct |
25 |
Correct |
44 ms |
82472 KB |
Output is correct |