Submission #1018123

# Submission time Handle Problem Language Result Execution time Memory
1018123 2024-07-09T14:56:53 Z stdfloat Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
#include "crocodile.h"
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;

            if (dis[x].ff != LLONG_MAX) q.push({-dis[x].ff, x});            
            continue;
        }

        for (auto [i, w] : E[x]) {
            if (d + w < dis[i].ss) {
                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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -