# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
716412 |
2023-03-30T04:53:39 Z |
ajab_01 |
Paths (BOI18_paths) |
C++17 |
|
487 ms |
96016 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3e5 + 5;
const int K = 5;
vector<int> g[N];
int dp[N][(1 << K)] , C[N] , ans , n , m , k;
int32_t main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m >> k;
for(int i = 1 ; i <= n ; i++){
cin >> C[i];
C[i]--;
dp[i][(1 << C[i])] = 1;
}
for(int i = 1 ; i <= m ; i++){
int u , v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
for(int mask = 1 ; mask < (1 << K) ; mask++){
if(__builtin_popcount(mask) == 1) continue;
for(int i = 1 ; i <= n ; i++){
if(mask & (1 << C[i])){
for(int j : g[i])
dp[i][mask] += dp[j][mask ^ (1 << C[i])];
ans += dp[i][mask];
}
}
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7380 KB |
Output is correct |
2 |
Correct |
4 ms |
7380 KB |
Output is correct |
3 |
Correct |
4 ms |
7380 KB |
Output is correct |
4 |
Correct |
4 ms |
7380 KB |
Output is correct |
5 |
Correct |
3 ms |
7380 KB |
Output is correct |
6 |
Correct |
4 ms |
7408 KB |
Output is correct |
7 |
Correct |
4 ms |
7380 KB |
Output is correct |
8 |
Correct |
4 ms |
7380 KB |
Output is correct |
9 |
Correct |
4 ms |
7380 KB |
Output is correct |
10 |
Correct |
4 ms |
7264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
15860 KB |
Output is correct |
2 |
Correct |
63 ms |
14592 KB |
Output is correct |
3 |
Correct |
472 ms |
95492 KB |
Output is correct |
4 |
Correct |
183 ms |
23168 KB |
Output is correct |
5 |
Correct |
158 ms |
23208 KB |
Output is correct |
6 |
Correct |
351 ms |
67776 KB |
Output is correct |
7 |
Correct |
446 ms |
95380 KB |
Output is correct |
8 |
Correct |
457 ms |
96016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7380 KB |
Output is correct |
2 |
Correct |
4 ms |
7380 KB |
Output is correct |
3 |
Correct |
4 ms |
7380 KB |
Output is correct |
4 |
Correct |
4 ms |
7380 KB |
Output is correct |
5 |
Correct |
3 ms |
7380 KB |
Output is correct |
6 |
Correct |
4 ms |
7408 KB |
Output is correct |
7 |
Correct |
4 ms |
7380 KB |
Output is correct |
8 |
Correct |
4 ms |
7380 KB |
Output is correct |
9 |
Correct |
4 ms |
7380 KB |
Output is correct |
10 |
Correct |
4 ms |
7264 KB |
Output is correct |
11 |
Correct |
104 ms |
15860 KB |
Output is correct |
12 |
Correct |
63 ms |
14592 KB |
Output is correct |
13 |
Correct |
472 ms |
95492 KB |
Output is correct |
14 |
Correct |
183 ms |
23168 KB |
Output is correct |
15 |
Correct |
158 ms |
23208 KB |
Output is correct |
16 |
Correct |
351 ms |
67776 KB |
Output is correct |
17 |
Correct |
446 ms |
95380 KB |
Output is correct |
18 |
Correct |
457 ms |
96016 KB |
Output is correct |
19 |
Correct |
73 ms |
15860 KB |
Output is correct |
20 |
Correct |
54 ms |
14624 KB |
Output is correct |
21 |
Correct |
449 ms |
95424 KB |
Output is correct |
22 |
Correct |
158 ms |
23308 KB |
Output is correct |
23 |
Correct |
153 ms |
23248 KB |
Output is correct |
24 |
Correct |
338 ms |
67892 KB |
Output is correct |
25 |
Correct |
460 ms |
95380 KB |
Output is correct |
26 |
Correct |
487 ms |
95916 KB |
Output is correct |
27 |
Correct |
54 ms |
14592 KB |
Output is correct |
28 |
Correct |
84 ms |
17996 KB |
Output is correct |
29 |
Correct |
477 ms |
95444 KB |
Output is correct |
30 |
Correct |
331 ms |
54868 KB |
Output is correct |
31 |
Correct |
314 ms |
54908 KB |
Output is correct |
32 |
Correct |
483 ms |
95292 KB |
Output is correct |
33 |
Correct |
5 ms |
7380 KB |
Output is correct |
34 |
Correct |
5 ms |
7392 KB |
Output is correct |
35 |
Correct |
4 ms |
7344 KB |
Output is correct |
36 |
Correct |
4 ms |
7380 KB |
Output is correct |
37 |
Correct |
4 ms |
7380 KB |
Output is correct |
38 |
Correct |
4 ms |
7380 KB |
Output is correct |
39 |
Correct |
3 ms |
7380 KB |
Output is correct |
40 |
Correct |
4 ms |
7396 KB |
Output is correct |
41 |
Correct |
4 ms |
7380 KB |
Output is correct |
42 |
Correct |
4 ms |
7376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
7252 KB |
Output is correct |
2 |
Correct |
22 ms |
9664 KB |
Output is correct |
3 |
Correct |
20 ms |
9684 KB |
Output is correct |
4 |
Correct |
117 ms |
36612 KB |
Output is correct |
5 |
Correct |
87 ms |
37092 KB |
Output is correct |
6 |
Correct |
127 ms |
36632 KB |
Output is correct |
7 |
Correct |
31 ms |
9552 KB |
Output is correct |
8 |
Correct |
126 ms |
36624 KB |
Output is correct |
9 |
Correct |
101 ms |
37056 KB |
Output is correct |
10 |
Correct |
108 ms |
37324 KB |
Output is correct |
11 |
Correct |
73 ms |
22860 KB |
Output is correct |
12 |
Correct |
82 ms |
29884 KB |
Output is correct |
13 |
Correct |
81 ms |
23176 KB |
Output is correct |
14 |
Correct |
124 ms |
36588 KB |
Output is correct |
15 |
Correct |
125 ms |
36752 KB |
Output is correct |
16 |
Correct |
4 ms |
7380 KB |
Output is correct |
17 |
Correct |
4 ms |
7380 KB |
Output is correct |
18 |
Correct |
4 ms |
7380 KB |
Output is correct |
19 |
Correct |
4 ms |
7380 KB |
Output is correct |
20 |
Correct |
4 ms |
7380 KB |
Output is correct |
21 |
Correct |
4 ms |
7380 KB |
Output is correct |
22 |
Correct |
4 ms |
7380 KB |
Output is correct |
23 |
Correct |
4 ms |
7380 KB |
Output is correct |
24 |
Correct |
4 ms |
7252 KB |
Output is correct |
25 |
Correct |
4 ms |
7380 KB |
Output is correct |