Submission #145575

#TimeUsernameProblemLanguageResultExecution timeMemory
145575surface03두 로봇 (KOI18_robot)C++14
100 / 100
97 ms12664 KiB
#include<bits/stdc++.h> using namespace std; vector<pair<int,int>>v[100010]; int n,st,ed,visit[100010]; void f(int now,int tot,int maxi){ if(now==ed){ printf("%d",tot-maxi); exit(0); } for(auto&i:v[now]){ if(visit[i.first])continue; visit[i.first]=1; f(i.first,tot+i.second,max(maxi,i.second)); visit[i.first]=0; } } int main(){ scanf("%d%d%d",&n,&st,&ed); for(int i=0,n1,n2,n3;i<n-1;i++){ scanf("%d%d%d",&n1,&n2,&n3); v[n1].push_back(make_pair(n2,n3)); v[n2].push_back(make_pair(n1,n3)); } visit[st]=1; f(st,0,0); }

Compilation message (stderr)

robot.cpp: In function 'int main()':
robot.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&st,&ed);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
robot.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&n1,&n2,&n3);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...