# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84740 | kjh5678 | 두 로봇 (KOI18_robot) | C++14 | 98 ms | 16784 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#if 01
#include <stdio.h>
#define MAX(x,y) ((x>y)?(x):(y))
int N, r1, r2;
typedef struct _idxarr
{
int node;
long long dist;
_idxarr* next;
_idxarr(){ node = dist = 0; next = (_idxarr*)0; };
_idxarr(int a, long long b, _idxarr* c){ node = a; dist = b; next = c; }
}ia;
ia arr[100010];
long long dist[100010];
long long max[100010];
int visit[100010];
void input()
{
scanf("%d %d %d", &N, &r1, &r2);
for (int i = 1; i <= N; i++)
{
int x, y, v;
scanf("%d%d%d", &x, &y, &v);
arr[x].next = new ia(y, v, arr[x].next);
arr[y].next = new ia(x, v, arr[y].next);
}
}
void DFS(int node, long long d, long long m)
{
dist[node] = d;
max[node] = m;
visit[node] = 1;
for (ia* src = &arr[node]; src->next; src = src->next)
{
if (visit[src->next->node]) continue;
DFS(src->next->node, d + src->next->dist, MAX(m, src->next->dist));
}
}
int main()
{
input();
DFS(r1, 0, 0);
printf("%lld", dist[r2] - max[r2]);
}
#endif
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |