답안 #984857

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
984857 2024-05-17T07:29:00 Z 54skyxenon 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
// https://oj.uz/problem/view/IOI11_crocodile

#include <bits/stdc++.h>
using namespace std;

#define int long long

vector<map<int, int>> graph;
vector<bool> is_exit;
vector<bool> visited;

int dfs(int curr) {
    if (is_exit[curr]) {
        return 0;
    }

    vector<int> distances;
    for (auto [nei, weight] : graph[curr]) {
        if (!visited[nei]) {
            visited[nei] = true;
            distances.push_back(weight + dfs(nei));
        }
    }

    sort(distances.begin(), distances.end());
    return distances[1];
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m, k;
    cin >> n >> m >> k;

    graph.resize(n);
    for (int i = 0; i < m; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        graph[u][v] = graph[v][u] = w;
    }

    is_exit.resize(n);
    visited.resize(n);
    for (int i = 0; i < k; i++) {
        int p;
        cin >> p;
        is_exit[p] = true;
    }

    visited[0] = true;
    cout << dfs(0) << '\n';
}

Compilation message

/usr/bin/ld: /tmp/ccXfK6I3.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc0wG8n4.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccXfK6I3.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status