Submission #1000563

# Submission time Handle Problem Language Result Execution time Memory
1000563 2024-06-17T19:00:12 Z VMaksimoski008 Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
1 ms 2396 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

    priority_queue<pii, vector<pii>, greater<pii> > pq;
    vector<bool> vis(N);
    vector<ll> dist(N, 1e18);
    vector<ll> ans[N];

    for(int i=0; i<K; i++) {
        dist[P[i]] = 0;
        pq.push({ 0, P[i] });
    }

    while(!pq.empty()) {
        auto [d, u] = pq.top(); pq.pop();

        if(ans[u].size() >= 2) continue;
        ans[u].push_back(d);

        for(auto &[v, w] : graph[u]) {
            if(dist[v] > d + w) {
                dist[v] = d + w;
                pq.push({ d + w, v });
            }
        }
    }

    sort(ans[0].begin(), ans[0].end());
    return ans[0].back();
}


# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -