# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
532648 |
2022-03-03T14:14:08 Z |
fatemetmhr |
Paths (BOI18_paths) |
C++17 |
|
306 ms |
61296 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int maxn5 = 3e5 + 10;
vector <int> adj[maxn5];
int a[maxn5];
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n, m, k; cin >> n >> m >> k;
ll dp[(1<<k) + 1][n + 2];
memset(dp, 0, sizeof dp);
for(int i = 0; i < n; i++){
cin >> a[i];
a[i]--;
dp[1<<a[i]][i] = 1;
}
for(int i = 0; i < m; i++){
int a, b; cin >> a >> b;
a--; b--;
adj[a].pb(b);
adj[b].pb(a);
}
ll ans = 0;
for(int mask = 1; mask < (1 << k); mask++) if(__builtin_popcount(mask) > 1)
for(int i = 0; i < n; i++) if((mask >> a[i])&1){
for(auto u : adj[i])
dp[mask][i] += dp[mask ^ (1 << a[i])][u];
ans += dp[mask][i];
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7244 KB |
Output is correct |
2 |
Correct |
4 ms |
7372 KB |
Output is correct |
3 |
Correct |
4 ms |
7368 KB |
Output is correct |
4 |
Correct |
4 ms |
7364 KB |
Output is correct |
5 |
Correct |
4 ms |
7340 KB |
Output is correct |
6 |
Correct |
4 ms |
7372 KB |
Output is correct |
7 |
Correct |
4 ms |
7244 KB |
Output is correct |
8 |
Correct |
6 ms |
7368 KB |
Output is correct |
9 |
Correct |
4 ms |
7244 KB |
Output is correct |
10 |
Correct |
5 ms |
7356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
14068 KB |
Output is correct |
2 |
Correct |
48 ms |
13216 KB |
Output is correct |
3 |
Correct |
261 ms |
42436 KB |
Output is correct |
4 |
Correct |
94 ms |
16328 KB |
Output is correct |
5 |
Correct |
77 ms |
15876 KB |
Output is correct |
6 |
Correct |
140 ms |
33336 KB |
Output is correct |
7 |
Correct |
200 ms |
42484 KB |
Output is correct |
8 |
Correct |
213 ms |
43060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7244 KB |
Output is correct |
2 |
Correct |
4 ms |
7372 KB |
Output is correct |
3 |
Correct |
4 ms |
7368 KB |
Output is correct |
4 |
Correct |
4 ms |
7364 KB |
Output is correct |
5 |
Correct |
4 ms |
7340 KB |
Output is correct |
6 |
Correct |
4 ms |
7372 KB |
Output is correct |
7 |
Correct |
4 ms |
7244 KB |
Output is correct |
8 |
Correct |
6 ms |
7368 KB |
Output is correct |
9 |
Correct |
4 ms |
7244 KB |
Output is correct |
10 |
Correct |
5 ms |
7356 KB |
Output is correct |
11 |
Correct |
63 ms |
14068 KB |
Output is correct |
12 |
Correct |
48 ms |
13216 KB |
Output is correct |
13 |
Correct |
261 ms |
42436 KB |
Output is correct |
14 |
Correct |
94 ms |
16328 KB |
Output is correct |
15 |
Correct |
77 ms |
15876 KB |
Output is correct |
16 |
Correct |
140 ms |
33336 KB |
Output is correct |
17 |
Correct |
200 ms |
42484 KB |
Output is correct |
18 |
Correct |
213 ms |
43060 KB |
Output is correct |
19 |
Correct |
71 ms |
14144 KB |
Output is correct |
20 |
Correct |
58 ms |
13212 KB |
Output is correct |
21 |
Correct |
219 ms |
42380 KB |
Output is correct |
22 |
Correct |
82 ms |
16392 KB |
Output is correct |
23 |
Correct |
81 ms |
15864 KB |
Output is correct |
24 |
Correct |
177 ms |
33336 KB |
Output is correct |
25 |
Correct |
203 ms |
42492 KB |
Output is correct |
26 |
Correct |
222 ms |
43156 KB |
Output is correct |
27 |
Correct |
53 ms |
13224 KB |
Output is correct |
28 |
Correct |
68 ms |
15700 KB |
Output is correct |
29 |
Correct |
306 ms |
61296 KB |
Output is correct |
30 |
Correct |
175 ms |
37680 KB |
Output is correct |
31 |
Correct |
165 ms |
37688 KB |
Output is correct |
32 |
Correct |
278 ms |
61208 KB |
Output is correct |
33 |
Correct |
4 ms |
7340 KB |
Output is correct |
34 |
Correct |
4 ms |
7372 KB |
Output is correct |
35 |
Correct |
4 ms |
7364 KB |
Output is correct |
36 |
Correct |
4 ms |
7244 KB |
Output is correct |
37 |
Correct |
4 ms |
7244 KB |
Output is correct |
38 |
Correct |
4 ms |
7244 KB |
Output is correct |
39 |
Correct |
4 ms |
7244 KB |
Output is correct |
40 |
Correct |
4 ms |
7372 KB |
Output is correct |
41 |
Correct |
4 ms |
7244 KB |
Output is correct |
42 |
Correct |
6 ms |
7372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7244 KB |
Output is correct |
2 |
Correct |
23 ms |
9272 KB |
Output is correct |
3 |
Correct |
19 ms |
9116 KB |
Output is correct |
4 |
Correct |
53 ms |
18808 KB |
Output is correct |
5 |
Correct |
44 ms |
19596 KB |
Output is correct |
6 |
Correct |
106 ms |
37660 KB |
Output is correct |
7 |
Correct |
22 ms |
9192 KB |
Output is correct |
8 |
Correct |
72 ms |
25164 KB |
Output is correct |
9 |
Correct |
48 ms |
25868 KB |
Output is correct |
10 |
Correct |
56 ms |
25920 KB |
Output is correct |
11 |
Correct |
76 ms |
23328 KB |
Output is correct |
12 |
Correct |
83 ms |
31028 KB |
Output is correct |
13 |
Correct |
55 ms |
23620 KB |
Output is correct |
14 |
Correct |
94 ms |
37692 KB |
Output is correct |
15 |
Correct |
105 ms |
37688 KB |
Output is correct |
16 |
Correct |
5 ms |
7244 KB |
Output is correct |
17 |
Correct |
5 ms |
7348 KB |
Output is correct |
18 |
Correct |
5 ms |
7264 KB |
Output is correct |
19 |
Correct |
4 ms |
7244 KB |
Output is correct |
20 |
Correct |
4 ms |
7284 KB |
Output is correct |
21 |
Correct |
4 ms |
7372 KB |
Output is correct |
22 |
Correct |
4 ms |
7368 KB |
Output is correct |
23 |
Correct |
4 ms |
7372 KB |
Output is correct |
24 |
Correct |
4 ms |
7244 KB |
Output is correct |
25 |
Correct |
4 ms |
7244 KB |
Output is correct |