# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069672 | 2024-08-22T08:01:19 Z | mc061 | Roller Coaster Railroad (IOI16_railroad) | C++14 | 37 ms | 15184 KB |
#pragma once #include <bits/stdc++.h> using namespace std; const int N = 16; int64_t ham_path[1<<N][N]; int64_t dist[N][N]; long long plan_roller_coaster(vector<int> s, vector<int> t) { const int n = s.size(); for (int i = 0; i < (1<<n); ++i) { fill(ham_path[i], ham_path[i]+n, 1e18); } ham_path[0][0] = 0; for (int i = 0; i < n; ++i) { ham_path[1<<i][i] = 0; } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i==j) { dist[i][j]=1e18; continue; } dist[i][j] = max(0, t[i]-s[j]); } } for (int m = 1; m < (1<<n); ++m) { vector<int> bits; for (int bit = 0; bit < n; ++bit) { if ((m & (1 << bit)) == 0) continue; bits.push_back(bit); } if (bits.size() == 1) { continue; } for (int i = 0; i < bits.size(); ++i) { int prev_m = m ^ (1 << bits[i]); assert(prev_m < m); for (int j = 0; j < bits.size(); ++j) { if (i == j) continue; ham_path[m][bits[i]] = min(ham_path[m][bits[i]], ham_path[prev_m][bits[j]] + dist[bits[j]][bits[i]]); } } } return *min_element(ham_path[(1<<n)-1], ham_path[(1<<n)-1]+n); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | n = 2 |
2 | Correct | 0 ms | 348 KB | n = 2 |
3 | Correct | 0 ms | 348 KB | n = 2 |
4 | Correct | 0 ms | 348 KB | n = 2 |
5 | Correct | 0 ms | 348 KB | n = 2 |
6 | Correct | 0 ms | 348 KB | n = 2 |
7 | Correct | 0 ms | 344 KB | n = 3 |
8 | Correct | 0 ms | 348 KB | n = 3 |
9 | Correct | 0 ms | 348 KB | n = 3 |
10 | Correct | 1 ms | 348 KB | n = 8 |
11 | Correct | 1 ms | 348 KB | n = 8 |
12 | Correct | 1 ms | 348 KB | n = 8 |
13 | Correct | 0 ms | 348 KB | n = 8 |
14 | Correct | 0 ms | 348 KB | n = 8 |
15 | Correct | 0 ms | 348 KB | n = 8 |
16 | Correct | 0 ms | 348 KB | n = 8 |
17 | Correct | 0 ms | 348 KB | n = 8 |
18 | Correct | 1 ms | 348 KB | n = 8 |
19 | Correct | 0 ms | 348 KB | n = 3 |
20 | Correct | 1 ms | 348 KB | n = 7 |
21 | Correct | 1 ms | 348 KB | n = 8 |
22 | Correct | 1 ms | 348 KB | n = 8 |
23 | Correct | 1 ms | 344 KB | n = 8 |
24 | Correct | 1 ms | 348 KB | n = 8 |
25 | Correct | 0 ms | 348 KB | n = 8 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | n = 2 |
2 | Correct | 0 ms | 348 KB | n = 2 |
3 | Correct | 0 ms | 348 KB | n = 2 |
4 | Correct | 0 ms | 348 KB | n = 2 |
5 | Correct | 0 ms | 348 KB | n = 2 |
6 | Correct | 0 ms | 348 KB | n = 2 |
7 | Correct | 0 ms | 344 KB | n = 3 |
8 | Correct | 0 ms | 348 KB | n = 3 |
9 | Correct | 0 ms | 348 KB | n = 3 |
10 | Correct | 1 ms | 348 KB | n = 8 |
11 | Correct | 1 ms | 348 KB | n = 8 |
12 | Correct | 1 ms | 348 KB | n = 8 |
13 | Correct | 0 ms | 348 KB | n = 8 |
14 | Correct | 0 ms | 348 KB | n = 8 |
15 | Correct | 0 ms | 348 KB | n = 8 |
16 | Correct | 0 ms | 348 KB | n = 8 |
17 | Correct | 0 ms | 348 KB | n = 8 |
18 | Correct | 1 ms | 348 KB | n = 8 |
19 | Correct | 0 ms | 348 KB | n = 3 |
20 | Correct | 1 ms | 348 KB | n = 7 |
21 | Correct | 1 ms | 348 KB | n = 8 |
22 | Correct | 1 ms | 348 KB | n = 8 |
23 | Correct | 1 ms | 344 KB | n = 8 |
24 | Correct | 1 ms | 348 KB | n = 8 |
25 | Correct | 0 ms | 348 KB | n = 8 |
26 | Correct | 0 ms | 348 KB | n = 8 |
27 | Correct | 0 ms | 348 KB | n = 8 |
28 | Correct | 0 ms | 348 KB | n = 8 |
29 | Correct | 18 ms | 8540 KB | n = 16 |
30 | Correct | 22 ms | 8796 KB | n = 16 |
31 | Correct | 18 ms | 8540 KB | n = 16 |
32 | Correct | 27 ms | 8640 KB | n = 16 |
33 | Correct | 18 ms | 8540 KB | n = 16 |
34 | Correct | 18 ms | 8536 KB | n = 16 |
35 | Correct | 19 ms | 8644 KB | n = 16 |
36 | Correct | 9 ms | 4700 KB | n = 15 |
37 | Correct | 0 ms | 348 KB | n = 8 |
38 | Correct | 24 ms | 8540 KB | n = 16 |
39 | Correct | 18 ms | 8540 KB | n = 16 |
40 | Correct | 1 ms | 344 KB | n = 9 |
41 | Correct | 19 ms | 8648 KB | n = 16 |
42 | Correct | 29 ms | 8644 KB | n = 16 |
43 | Correct | 19 ms | 8536 KB | n = 16 |
44 | Correct | 1 ms | 348 KB | n = 9 |
45 | Correct | 9 ms | 4700 KB | n = 15 |
46 | Correct | 19 ms | 8648 KB | n = 16 |
47 | Correct | 19 ms | 8536 KB | n = 16 |
48 | Correct | 29 ms | 8652 KB | n = 16 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 37 ms | 15184 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | n = 2 |
2 | Correct | 0 ms | 348 KB | n = 2 |
3 | Correct | 0 ms | 348 KB | n = 2 |
4 | Correct | 0 ms | 348 KB | n = 2 |
5 | Correct | 0 ms | 348 KB | n = 2 |
6 | Correct | 0 ms | 348 KB | n = 2 |
7 | Correct | 0 ms | 344 KB | n = 3 |
8 | Correct | 0 ms | 348 KB | n = 3 |
9 | Correct | 0 ms | 348 KB | n = 3 |
10 | Correct | 1 ms | 348 KB | n = 8 |
11 | Correct | 1 ms | 348 KB | n = 8 |
12 | Correct | 1 ms | 348 KB | n = 8 |
13 | Correct | 0 ms | 348 KB | n = 8 |
14 | Correct | 0 ms | 348 KB | n = 8 |
15 | Correct | 0 ms | 348 KB | n = 8 |
16 | Correct | 0 ms | 348 KB | n = 8 |
17 | Correct | 0 ms | 348 KB | n = 8 |
18 | Correct | 1 ms | 348 KB | n = 8 |
19 | Correct | 0 ms | 348 KB | n = 3 |
20 | Correct | 1 ms | 348 KB | n = 7 |
21 | Correct | 1 ms | 348 KB | n = 8 |
22 | Correct | 1 ms | 348 KB | n = 8 |
23 | Correct | 1 ms | 344 KB | n = 8 |
24 | Correct | 1 ms | 348 KB | n = 8 |
25 | Correct | 0 ms | 348 KB | n = 8 |
26 | Correct | 0 ms | 348 KB | n = 8 |
27 | Correct | 0 ms | 348 KB | n = 8 |
28 | Correct | 0 ms | 348 KB | n = 8 |
29 | Correct | 18 ms | 8540 KB | n = 16 |
30 | Correct | 22 ms | 8796 KB | n = 16 |
31 | Correct | 18 ms | 8540 KB | n = 16 |
32 | Correct | 27 ms | 8640 KB | n = 16 |
33 | Correct | 18 ms | 8540 KB | n = 16 |
34 | Correct | 18 ms | 8536 KB | n = 16 |
35 | Correct | 19 ms | 8644 KB | n = 16 |
36 | Correct | 9 ms | 4700 KB | n = 15 |
37 | Correct | 0 ms | 348 KB | n = 8 |
38 | Correct | 24 ms | 8540 KB | n = 16 |
39 | Correct | 18 ms | 8540 KB | n = 16 |
40 | Correct | 1 ms | 344 KB | n = 9 |
41 | Correct | 19 ms | 8648 KB | n = 16 |
42 | Correct | 29 ms | 8644 KB | n = 16 |
43 | Correct | 19 ms | 8536 KB | n = 16 |
44 | Correct | 1 ms | 348 KB | n = 9 |
45 | Correct | 9 ms | 4700 KB | n = 15 |
46 | Correct | 19 ms | 8648 KB | n = 16 |
47 | Correct | 19 ms | 8536 KB | n = 16 |
48 | Correct | 29 ms | 8652 KB | n = 16 |
49 | Runtime error | 37 ms | 15184 KB | Execution killed with signal 11 |
50 | Halted | 0 ms | 0 KB | - |