# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034643 | 2024-07-25T15:45:06 Z | anango | Paths (BOI18_paths) | C++17 | 387 ms | 62292 KB |
#include <bits/stdc++.h> #define int long long using namespace std; int INF = 1LL<<30; signed main() { #ifdef ONLINE_JUDGE ios_base::sync_with_stdio(false); cin.tie(NULL); #endif //fast IO int n,m,k; cin >> n >> m >> k; vector<vector<int>> adjlist(n); vector<int> col(n); for (int i=0; i<n; i++) {cin >> col[i]; col[i]--;} for (int i=0; i<m; i++) { int u,v; cin >> u >> v; u--; v--; adjlist[u].push_back(v); adjlist[v].push_back(u); } int dp[n][1<<k]; for (int i=0; i<n; i++) { for (int j=0; j<1<<k; j++) { dp[i][j] = 0; } } //dp[i][j] = number of paths with this bitmask of colours used, ending in this vertex for (int i=0; i<n; i++) { dp[i][1<<col[i]]++; } for (int mask=1; mask<1<<k; mask++) { for (int i=0; i<n; i++) { if (mask&(1<<col[i])==0) continue; for (int j:adjlist[i]) { dp[i][mask]+=dp[j][mask^(1<<col[i])]; } } } int su=0; for (int i=0; i<n; i++) { for (int j=0; j<1<<k; j++) { su+=dp[i][j]; } } cout << su-n << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 96 ms | 10652 KB | Output is correct |
2 | Correct | 77 ms | 9812 KB | Output is correct |
3 | Correct | 242 ms | 43492 KB | Output is correct |
4 | Correct | 121 ms | 13652 KB | Output is correct |
5 | Correct | 118 ms | 13140 KB | Output is correct |
6 | Correct | 193 ms | 32188 KB | Output is correct |
7 | Correct | 244 ms | 43604 KB | Output is correct |
8 | Correct | 263 ms | 43988 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 96 ms | 10652 KB | Output is correct |
12 | Correct | 77 ms | 9812 KB | Output is correct |
13 | Correct | 242 ms | 43492 KB | Output is correct |
14 | Correct | 121 ms | 13652 KB | Output is correct |
15 | Correct | 118 ms | 13140 KB | Output is correct |
16 | Correct | 193 ms | 32188 KB | Output is correct |
17 | Correct | 244 ms | 43604 KB | Output is correct |
18 | Correct | 263 ms | 43988 KB | Output is correct |
19 | Correct | 96 ms | 10832 KB | Output is correct |
20 | Correct | 82 ms | 9660 KB | Output is correct |
21 | Correct | 261 ms | 43600 KB | Output is correct |
22 | Correct | 125 ms | 13648 KB | Output is correct |
23 | Correct | 120 ms | 13136 KB | Output is correct |
24 | Correct | 200 ms | 31940 KB | Output is correct |
25 | Correct | 243 ms | 43604 KB | Output is correct |
26 | Correct | 307 ms | 44116 KB | Output is correct |
27 | Correct | 83 ms | 9812 KB | Output is correct |
28 | Correct | 115 ms | 13040 KB | Output is correct |
29 | Correct | 387 ms | 62152 KB | Output is correct |
30 | Correct | 240 ms | 36628 KB | Output is correct |
31 | Correct | 261 ms | 36552 KB | Output is correct |
32 | Correct | 374 ms | 62292 KB | Output is correct |
33 | Correct | 0 ms | 344 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
37 | Correct | 0 ms | 348 KB | Output is correct |
38 | Correct | 1 ms | 348 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 0 ms | 348 KB | Output is correct |
41 | Correct | 0 ms | 344 KB | Output is correct |
42 | Correct | 0 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Correct | 31 ms | 3488 KB | Output is correct |
3 | Correct | 26 ms | 3164 KB | Output is correct |
4 | Correct | 62 ms | 14520 KB | Output is correct |
5 | Correct | 55 ms | 14900 KB | Output is correct |
6 | Correct | 124 ms | 33344 KB | Output is correct |
7 | Correct | 28 ms | 3160 KB | Output is correct |
8 | Correct | 79 ms | 20800 KB | Output is correct |
9 | Correct | 68 ms | 21192 KB | Output is correct |
10 | Correct | 80 ms | 20936 KB | Output is correct |
11 | Correct | 71 ms | 18276 KB | Output is correct |
12 | Correct | 85 ms | 25920 KB | Output is correct |
13 | Correct | 73 ms | 18384 KB | Output is correct |
14 | Correct | 126 ms | 33448 KB | Output is correct |
15 | Correct | 135 ms | 33784 KB | Output is correct |
16 | Correct | 0 ms | 344 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 432 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Correct | 0 ms | 344 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |