답안 #1007003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007003 2024-06-24T10:44:09 Z overwatch9 Toll (BOI17_toll) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 50001;
vector <pair <int, int>> adj[maxn];
ll dis[maxn];
ll tparr[maxn][maxn];
bool processed[maxn];
queue <int> modified;
int pos[maxn];
vector <vector <ll>> pfx;
int id[maxn];
ll dijkstra(int st, int ed) {
    dis[st] = 0;
    priority_queue <pair <ll, int>> pq;
    pq.push({0, st});
    pos[st] = 0;
    while (!pq.empty()) {
        int s = pq.top().second;
        pq.pop();
        if (processed[s])
            continue;
        processed[s] = true;
        modified.push(s);
        id[s] = (int)pfx.size()-1;
        pfx.back().push_back(dis[s]);
        for (auto i : adj[s]) {
            if (dis[i.first] > dis[s] + i.second) {
                dis[i.first] = dis[s] + i.second;
                pq.push({-dis[i.first], i.first});
                pos[i.first] = pos[s] + 1;
            }
        }
    }
    ll ans = 0;
    if (dis[ed] == 1e18) {
        dis[ed] = -1;
        modified.push(ed);
    }
    ans = dis[ed];
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int K, N, M, O;
    cin >> K >> N >> M >> O;
    for (int i = 0; i < M; i++) {
        int a, b, t;
        cin >> a >> b >> t;
        adj[a].push_back({b, t});
    }
    fill(dis, dis + N + 1, 1e18);
    pfx.emplace_back();
    for (int i = 0; i < N; i++) {
        if (!adj[i].empty() && !processed[i]) {
            pfx.emplace_back();
            dijkstra(i, i);
        }
    }
    while (O--) {
        int a, b;
        cin >> a >> b;
        if (id[a] != id[b] || min(id[a], id[b]) == 0)
            cout << -1 << '\n';
        else
            cout << pfx[id[a]][pos[b]] - pfx[id[a]][pos[a]] << '\n';
    }
}

Compilation message

/tmp/ccv5iQag.o: in function `__tcf_0':
toll.cpp:(.text+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `adj' defined in .bss section in /tmp/ccv5iQag.o
/tmp/ccv5iQag.o: in function `dijkstra(int, int)':
toll.cpp:(.text+0xf4): relocation truncated to fit: R_X86_64_PC32 against symbol `dis' defined in .bss section in /tmp/ccv5iQag.o
toll.cpp:(.text+0x392): relocation truncated to fit: R_X86_64_PC32 against symbol `adj' defined in .bss section in /tmp/ccv5iQag.o
/tmp/ccv5iQag.o: in function `main':
toll.cpp:(.text.startup+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
toll.cpp:(.text.startup+0x38): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
toll.cpp:(.text.startup+0x43): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
toll.cpp:(.text.startup+0x98): relocation truncated to fit: R_X86_64_PC32 against symbol `adj' defined in .bss section in /tmp/ccv5iQag.o
toll.cpp:(.text.startup+0xca): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
toll.cpp:(.text.startup+0x130): relocation truncated to fit: R_X86_64_PC32 against symbol `dis' defined in .bss section in /tmp/ccv5iQag.o
toll.cpp:(.text.startup+0x19c): relocation truncated to fit: R_X86_64_PC32 against symbol `adj' defined in .bss section in /tmp/ccv5iQag.o
toll.cpp:(.text.startup+0x260): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status