| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 544674 | pokmui9909 | 두 로봇 (KOI18_robot) | C++17 | 114 ms | 13180 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> tree[100005];
int cost1[100005], cost2[100005];
int visited[100005];
int n, x, y;
void dfs1(int node, int c)
{
    visited[node] = 1;
    cost1[node] = c;
    for(int i = 0; i < tree[node].size(); i++)
    {
        int next = tree[node][i].first;
        if(visited[next]) continue;
        dfs1(next, c + tree[node][i].second);
    }
}
void dfs2(int node, int c)
{
    visited[node] = 1;
    cost2[node] = c;
    for(int i = 0; i < tree[node].size(); i++)
    {
        int next = tree[node][i].first;
        if(visited[next]) continue;
        dfs2(next, c + tree[node][i].second);
    }
}
int main()
{
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> n >> x >> y;
    if(x == y)
    {
        cout << 0;
        return 0;
    }
    for(int i = 1; i <= n - 1; i++)
    {
        int a, b, c; cin >> a >> b >> c;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }
    dfs1(x, 0);
    for(int i = 1; i <= n; i++)
        visited[i] = 0;
    dfs2(y, 0);
    //for(int i = 1; i <= n; i++)
        //cout << cost1[i] << ' ';
    int ans = INT_MAX;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j < tree[i].size(); j++)
        {
            ans = min(ans, cost1[i] + cost2[tree[i][j].first]);
        }
    }
    cout << ans;
}
컴파일 시 표준 에러 (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... | ||||
