Submission #63169

#TimeUsernameProblemLanguageResultExecution timeMemory
63169kjp4155두 로봇 (KOI18_robot)C++17
100 / 100
176 ms59156 KiB
#include <stdio.h> #include <algorithm> #include <utility> #include <vector> using namespace std; int N,A,B; vector<pair<int,int>> E[100500]; // dist는 루트로부터 해당 정점까지 거리를 저장하는 배열 // mx는 루트로부터 해당 정점까지 경로상 가장 긴 통로의 길이를 저장하는 배열 int D[100500], M[100500]; bool vis[100500]; void dfs(int node, int d, int m){ D[node] = d; M[node] = m; vis[node] = true; for(pair<int,int> e : E[node]){ if( !vis[e.first] ) dfs(e.first, d + e.second, max(m, e.second) ); } } int main(){ scanf("%d%d%d",&N,&A,&B); for(int i=1;i<=N-1;i++){ int x,y,z; scanf("%d%d%d",&x,&y,&z); E[x].push_back(make_pair(y,z)); E[y].push_back(make_pair(x,z)); } dfs(A,0,0); printf("%d\n",D[B]-M[B]); }

Compilation message (stderr)

robot.cpp: In function 'int main()':
robot.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&N,&A,&B);
  ~~~~~^~~~~~~~~~~~~~~~~~~
robot.cpp:27:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x,y,z; scanf("%d%d%d",&x,&y,&z);
              ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...