답안 #1018144

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018144 2024-07-09T15:19:45 Z stdfloat 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "crocodile.h"
#include "grader.cpp"
using namespace std;

#define ff  first
#define ss  second
#define pii pair<int, int>

using ll = long long;

int travel_plan(int n, int M, int R[][2], int L[], int K, int P[]) {
    vector<vector<pii>> E(n);
    for (int i = 0; i < M; i++) {
        E[R[i][0]].push_back({R[i][1], L[i]});
        E[R[i][1]].push_back({R[i][0], L[i]});
    }

    vector<bool> vis(n);
    vector<pair<ll, ll>> dis(n, {LLONG_MAX, LLONG_MAX});
    priority_queue<pair<ll, int>> q;
    for (int i = 0; i < K; i++) {
        vis[P[i]] = true;
        dis[P[i]] = {0, 0};
        q.push({0, P[i]});
    }

    while (!q.empty()) {
        auto [d, x] = q.top(); d = -d; q.pop();
    
        if (d != dis[x].ff) continue;

        if (!vis[x]) {
            vis[x] = true;

            dis[x].ff = dis[x].ss;
            dis[x].ss = LLONG_MAX;         
            continue;
        }

        for (auto [i, w] : E[x]) {
            if (d + w < dis[i].ss && (!vis[i] || d + w < dis[i].ff)) {
                dis[i].ss = d + w;

                if (dis[i].ff > dis[i].ss) swap(dis[i].ff, dis[i].ss);

                q.push({-d - w, i});
            }
        }
    }

    return (dis[0].ff == LLONG_MAX ? -1 : dis[0].ff);
}

Compilation message

/usr/bin/ld: /tmp/ccN0E6d8.o: in function `read_input()':
grader.cpp:(.text+0x0): multiple definition of `read_input()'; /tmp/cc6J5jo9.o:crocodile.cpp:(.text+0x90): first defined here
/usr/bin/ld: /tmp/ccN0E6d8.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc6J5jo9.o:crocodile.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status