# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
283415 | 2020-08-25T16:55:44 Z | AlexLuchianov | Paths (BOI18_paths) | C++14 | 1129 ms | 97400 KB |
#include <iostream> #include <vector> #include <cassert> #include <cmath> using ll = long long; #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) < (b)) ? (b) : (a)) int const nmax = 300000; int const sigma = 5; int v[1 + nmax]; ll dp[1 + nmax][1 << sigma]; std::vector<int> g[1 + nmax]; int main() { int n, m, k; std::cin >> n >> m >> k; for(int i = 1;i <= n; i++) { std::cin >> v[i]; v[i]--; } for(int i = 1;i <= m; i++) { int x, y; std::cin >> x >> y; g[x].push_back(y); g[y].push_back(x); } ll result = 0; for(int mask = 1; mask < (1 << sigma); mask++) { for(int i = 1; i <= n; i++) { if(0 < ((1 << v[i]) & mask)) { if(0 < ((1 << v[i]) ^ mask)) { for(int h = 0; h < g[i].size(); h++) { int to = g[i][h]; dp[i][mask] += dp[to][mask ^ (1 << v[i])]; } } else dp[i][mask] = 1; } result += dp[i][mask]; } } std::cout << result - n; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 7328 KB | Output is correct |
2 | Correct | 5 ms | 7424 KB | Output is correct |
3 | Correct | 5 ms | 7424 KB | Output is correct |
4 | Correct | 6 ms | 7680 KB | Output is correct |
5 | Correct | 5 ms | 7424 KB | Output is correct |
6 | Correct | 7 ms | 7424 KB | Output is correct |
7 | Correct | 5 ms | 7424 KB | Output is correct |
8 | Correct | 5 ms | 7424 KB | Output is correct |
9 | Correct | 5 ms | 7424 KB | Output is correct |
10 | Correct | 6 ms | 7424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 331 ms | 12280 KB | Output is correct |
2 | Correct | 273 ms | 11104 KB | Output is correct |
3 | Correct | 1079 ms | 96376 KB | Output is correct |
4 | Correct | 508 ms | 22860 KB | Output is correct |
5 | Correct | 508 ms | 22904 KB | Output is correct |
6 | Correct | 846 ms | 69608 KB | Output is correct |
7 | Correct | 1091 ms | 96632 KB | Output is correct |
8 | Correct | 1094 ms | 97400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 7328 KB | Output is correct |
2 | Correct | 5 ms | 7424 KB | Output is correct |
3 | Correct | 5 ms | 7424 KB | Output is correct |
4 | Correct | 6 ms | 7680 KB | Output is correct |
5 | Correct | 5 ms | 7424 KB | Output is correct |
6 | Correct | 7 ms | 7424 KB | Output is correct |
7 | Correct | 5 ms | 7424 KB | Output is correct |
8 | Correct | 5 ms | 7424 KB | Output is correct |
9 | Correct | 5 ms | 7424 KB | Output is correct |
10 | Correct | 6 ms | 7424 KB | Output is correct |
11 | Correct | 331 ms | 12280 KB | Output is correct |
12 | Correct | 273 ms | 11104 KB | Output is correct |
13 | Correct | 1079 ms | 96376 KB | Output is correct |
14 | Correct | 508 ms | 22860 KB | Output is correct |
15 | Correct | 508 ms | 22904 KB | Output is correct |
16 | Correct | 846 ms | 69608 KB | Output is correct |
17 | Correct | 1091 ms | 96632 KB | Output is correct |
18 | Correct | 1094 ms | 97400 KB | Output is correct |
19 | Correct | 333 ms | 15084 KB | Output is correct |
20 | Correct | 272 ms | 13560 KB | Output is correct |
21 | Correct | 1082 ms | 96632 KB | Output is correct |
22 | Correct | 542 ms | 22848 KB | Output is correct |
23 | Correct | 549 ms | 22776 KB | Output is correct |
24 | Correct | 816 ms | 69424 KB | Output is correct |
25 | Correct | 1063 ms | 96524 KB | Output is correct |
26 | Correct | 1078 ms | 97248 KB | Output is correct |
27 | Correct | 293 ms | 13304 KB | Output is correct |
28 | Correct | 390 ms | 16800 KB | Output is correct |
29 | Correct | 1129 ms | 96632 KB | Output is correct |
30 | Correct | 787 ms | 55536 KB | Output is correct |
31 | Correct | 778 ms | 55664 KB | Output is correct |
32 | Correct | 1081 ms | 96504 KB | Output is correct |
33 | Correct | 5 ms | 7424 KB | Output is correct |
34 | Correct | 5 ms | 7424 KB | Output is correct |
35 | Correct | 5 ms | 7424 KB | Output is correct |
36 | Correct | 5 ms | 7424 KB | Output is correct |
37 | Correct | 5 ms | 7424 KB | Output is correct |
38 | Correct | 5 ms | 7424 KB | Output is correct |
39 | Correct | 5 ms | 7424 KB | Output is correct |
40 | Correct | 6 ms | 7424 KB | Output is correct |
41 | Correct | 5 ms | 7424 KB | Output is correct |
42 | Correct | 5 ms | 7424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 7424 KB | Output is correct |
2 | Correct | 91 ms | 8824 KB | Output is correct |
3 | Correct | 91 ms | 8824 KB | Output is correct |
4 | Correct | 314 ms | 35908 KB | Output is correct |
5 | Correct | 244 ms | 36592 KB | Output is correct |
6 | Correct | 314 ms | 35832 KB | Output is correct |
7 | Correct | 92 ms | 8776 KB | Output is correct |
8 | Correct | 324 ms | 35832 KB | Output is correct |
9 | Correct | 252 ms | 36588 KB | Output is correct |
10 | Correct | 295 ms | 36448 KB | Output is correct |
11 | Correct | 217 ms | 22260 KB | Output is correct |
12 | Correct | 224 ms | 29552 KB | Output is correct |
13 | Correct | 209 ms | 22256 KB | Output is correct |
14 | Correct | 353 ms | 35960 KB | Output is correct |
15 | Correct | 325 ms | 35988 KB | Output is correct |
16 | Correct | 5 ms | 7424 KB | Output is correct |
17 | Correct | 5 ms | 7424 KB | Output is correct |
18 | Correct | 6 ms | 7424 KB | Output is correct |
19 | Correct | 5 ms | 7424 KB | Output is correct |
20 | Correct | 5 ms | 7424 KB | Output is correct |
21 | Correct | 5 ms | 7424 KB | Output is correct |
22 | Correct | 6 ms | 7424 KB | Output is correct |
23 | Correct | 5 ms | 7424 KB | Output is correct |
24 | Correct | 5 ms | 7552 KB | Output is correct |
25 | Correct | 5 ms | 7424 KB | Output is correct |