# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65666 | 2018-08-08T11:12:18 Z | imeimi2000 | None (KOI18_robot) | C++17 | 139 ms | 59008 KB |
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_map> #include <functional> #include <cstring> #include <cmath> #include <ctime> #include <cstdlib> using namespace std; typedef long long llong; typedef long double ld; typedef pair<int, int> pii; typedef pair<llong, llong> pll; struct _edge { int x, c; _edge(int x, int c) : x(x), c(c) {} }; int n, s, e; vector<_edge> edge[100001]; int mx[100001]; int dist[100001]; void dfs(int x, int p) { for (_edge i : edge[x]) { if (i.x == p) continue; mx[i.x] = max(mx[x], i.c); dist[i.x] = dist[x] + i.c; dfs(i.x, x); } } int main() { scanf("%d%d%d", &n, &s, &e); for (int i = 1; i < n; ++i) { int a, b, c; scanf("%d%d%d", &a, &b, &c); edge[a].emplace_back(b, c); edge[b].emplace_back(a, c); } dfs(s, 0); printf("%d\n", dist[e] - mx[e]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 12792 KB | Output is correct |
2 | Correct | 57 ms | 13432 KB | Output is correct |
3 | Correct | 53 ms | 13440 KB | Output is correct |
4 | Correct | 5 ms | 13440 KB | Output is correct |
5 | Correct | 12 ms | 13440 KB | Output is correct |
6 | Correct | 15 ms | 13440 KB | Output is correct |
7 | Correct | 4 ms | 13440 KB | Output is correct |
8 | Correct | 19 ms | 13440 KB | Output is correct |
9 | Correct | 5 ms | 13440 KB | Output is correct |
10 | Correct | 17 ms | 13440 KB | Output is correct |
11 | Correct | 4 ms | 13440 KB | Output is correct |
12 | Correct | 4 ms | 13440 KB | Output is correct |
13 | Correct | 21 ms | 13440 KB | Output is correct |
14 | Correct | 39 ms | 13440 KB | Output is correct |
15 | Correct | 6 ms | 13440 KB | Output is correct |
16 | Correct | 26 ms | 13440 KB | Output is correct |
17 | Correct | 30 ms | 14288 KB | Output is correct |
18 | Correct | 33 ms | 15156 KB | Output is correct |
19 | Correct | 7 ms | 15156 KB | Output is correct |
20 | Correct | 36 ms | 16772 KB | Output is correct |
21 | Correct | 39 ms | 18268 KB | Output is correct |
22 | Correct | 45 ms | 21280 KB | Output is correct |
23 | Correct | 8 ms | 21280 KB | Output is correct |
24 | Correct | 58 ms | 22136 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 93 ms | 22704 KB | Output is correct |
2 | Correct | 61 ms | 25136 KB | Output is correct |
3 | Correct | 7 ms | 25136 KB | Output is correct |
4 | Correct | 5 ms | 25136 KB | Output is correct |
5 | Correct | 17 ms | 25136 KB | Output is correct |
6 | Correct | 12 ms | 25136 KB | Output is correct |
7 | Correct | 5 ms | 25136 KB | Output is correct |
8 | Correct | 16 ms | 25136 KB | Output is correct |
9 | Correct | 20 ms | 25136 KB | Output is correct |
10 | Correct | 5 ms | 25136 KB | Output is correct |
11 | Correct | 25 ms | 25136 KB | Output is correct |
12 | Correct | 38 ms | 25136 KB | Output is correct |
13 | Correct | 9 ms | 25136 KB | Output is correct |
14 | Correct | 6 ms | 25136 KB | Output is correct |
15 | Correct | 50 ms | 25136 KB | Output is correct |
16 | Correct | 32 ms | 25996 KB | Output is correct |
17 | Correct | 40 ms | 27508 KB | Output is correct |
18 | Correct | 56 ms | 27508 KB | Output is correct |
19 | Correct | 52 ms | 31808 KB | Output is correct |
20 | Correct | 66 ms | 31808 KB | Output is correct |
21 | Correct | 10 ms | 31808 KB | Output is correct |
22 | Correct | 12 ms | 31808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 31808 KB | Output is correct |
2 | Correct | 6 ms | 31808 KB | Output is correct |
3 | Correct | 7 ms | 31808 KB | Output is correct |
4 | Correct | 5 ms | 31808 KB | Output is correct |
5 | Correct | 7 ms | 31808 KB | Output is correct |
6 | Correct | 6 ms | 31808 KB | Output is correct |
7 | Correct | 7 ms | 31808 KB | Output is correct |
8 | Correct | 5 ms | 31808 KB | Output is correct |
9 | Correct | 5 ms | 31808 KB | Output is correct |
10 | Correct | 8 ms | 31808 KB | Output is correct |
11 | Correct | 8 ms | 31808 KB | Output is correct |
12 | Correct | 8 ms | 31808 KB | Output is correct |
13 | Correct | 8 ms | 31808 KB | Output is correct |
14 | Correct | 8 ms | 31808 KB | Output is correct |
15 | Correct | 8 ms | 31808 KB | Output is correct |
16 | Correct | 5 ms | 31808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 99 ms | 33748 KB | Output is correct |
2 | Correct | 115 ms | 35024 KB | Output is correct |
3 | Correct | 63 ms | 40032 KB | Output is correct |
4 | Correct | 58 ms | 40592 KB | Output is correct |
5 | Correct | 53 ms | 40592 KB | Output is correct |
6 | Correct | 139 ms | 44496 KB | Output is correct |
7 | Correct | 7 ms | 44496 KB | Output is correct |
8 | Correct | 6 ms | 44496 KB | Output is correct |
9 | Correct | 6 ms | 44496 KB | Output is correct |
10 | Correct | 11 ms | 44496 KB | Output is correct |
11 | Correct | 7 ms | 44496 KB | Output is correct |
12 | Correct | 15 ms | 44496 KB | Output is correct |
13 | Correct | 20 ms | 44496 KB | Output is correct |
14 | Correct | 13 ms | 44496 KB | Output is correct |
15 | Correct | 4 ms | 44496 KB | Output is correct |
16 | Correct | 6 ms | 44496 KB | Output is correct |
17 | Correct | 18 ms | 44496 KB | Output is correct |
18 | Correct | 6 ms | 44496 KB | Output is correct |
19 | Correct | 20 ms | 44496 KB | Output is correct |
20 | Correct | 22 ms | 44496 KB | Output is correct |
21 | Correct | 23 ms | 44496 KB | Output is correct |
22 | Correct | 8 ms | 44496 KB | Output is correct |
23 | Correct | 6 ms | 44496 KB | Output is correct |
24 | Correct | 5 ms | 44496 KB | Output is correct |
25 | Correct | 6 ms | 44496 KB | Output is correct |
26 | Correct | 22 ms | 44496 KB | Output is correct |
27 | Correct | 7 ms | 44496 KB | Output is correct |
28 | Correct | 23 ms | 44496 KB | Output is correct |
29 | Correct | 32 ms | 44496 KB | Output is correct |
30 | Correct | 31 ms | 44496 KB | Output is correct |
31 | Correct | 7 ms | 44496 KB | Output is correct |
32 | Correct | 9 ms | 44496 KB | Output is correct |
33 | Correct | 6 ms | 44496 KB | Output is correct |
34 | Correct | 34 ms | 44496 KB | Output is correct |
35 | Correct | 9 ms | 44496 KB | Output is correct |
36 | Correct | 42 ms | 44496 KB | Output is correct |
37 | Correct | 61 ms | 44984 KB | Output is correct |
38 | Correct | 28 ms | 46656 KB | Output is correct |
39 | Correct | 7 ms | 46656 KB | Output is correct |
40 | Correct | 5 ms | 46656 KB | Output is correct |
41 | Correct | 40 ms | 47648 KB | Output is correct |
42 | Correct | 9 ms | 47648 KB | Output is correct |
43 | Correct | 41 ms | 49132 KB | Output is correct |
44 | Correct | 49 ms | 49132 KB | Output is correct |
45 | Correct | 49 ms | 49784 KB | Output is correct |
46 | Correct | 45 ms | 52468 KB | Output is correct |
47 | Correct | 47 ms | 55616 KB | Output is correct |
48 | Correct | 79 ms | 55616 KB | Output is correct |
49 | Correct | 73 ms | 55616 KB | Output is correct |
50 | Correct | 9 ms | 55616 KB | Output is correct |
51 | Correct | 11 ms | 55616 KB | Output is correct |
52 | Correct | 10 ms | 55616 KB | Output is correct |
53 | Correct | 50 ms | 59008 KB | Output is correct |