# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145575 | surface03 | 두 로봇 (KOI18_robot) | C++14 | 97 ms | 12664 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.
#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)
# | 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... |