# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
102660 | sean9892 | 두 로봇 (KOI18_robot) | C++14 | 1091 ms | 188000 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main(void){
int n,s,e;
scanf("%d%d%d",&n,&s,&e);
map<pair<int,int>,int> adj;
for(int i=0;i<n-1;i++){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
adj[{a,b}]=adj[{b,a}]=c;
}
stack<int> st;
st.push(s);st.push(0);
int root[n+1];
memset(root,0,sizeof(root));
while(!st.empty()){
int b=st.top();st.pop();
int t=st.top();st.pop();
root[t]=b;
if(e==t){
break;
}
for(int i=1;i<=n;i++){
if(!root[i]&&adj[{i,t}]){
st.push(i);st.push(t);
}
}
}
int p=e;
int m=0;
int rl=0;
for(;p!=s;p=root[p]){
int x=adj[{p,root[p]}];
m=m>x?m:x;
rl+=x;
}
printf("%d",rl-m);
}
컴파일 시 표준 에러 (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... |