Submission #65666

#TimeUsernameProblemLanguageResultExecution timeMemory
65666imeimi2000두 로봇 (KOI18_robot)C++17
100 / 100
139 ms59008 KiB
#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 (stderr)

robot.cpp: In function 'int main()':
robot.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &s, &e);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
robot.cpp:44:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &a, &b, &c);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...