Submission #926816

# Submission time Handle Problem Language Result Execution time Memory
926816 2024-02-13T20:19:21 Z tomb Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
2000 ms 4440 KB
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vb vector<bool>
#define vvb vector<vb>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpii vector<pii>
#define vpli vector<pli>
#define vpil vector<pil>
#define vpll vector<pll>
#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define f first
#define s second
#define pb push_back
#define MAXN (int) 1e5


ll travel_plan(int n, int m, int R[][2], int *L, int k, int *P){
    vector<vpll> adj(n);
    for (int i = 0; i < m; i++)
        adj[R[i][0]].pb({R[i][1], L[i]}), adj[R[i][1]].pb({R[i][0], L[i]});
    
    priority_queue<pli, vpli, greater<pli>> pq;
    vll dist(n, 2e18), dist2(n, 2e18), par(n, -1);
    for (int i = 0; i < k; i++){
        dist[P[i]] = dist2[P[i]] = 0;
        pq.push({0, P[i]});
    }
    vb vis(n);
    dist[0] = dist2[0] = 0;
    while (pq.size()){
        int u; ll w;
        tie (w, u) = pq.top();
        if (vis[u]) continue;
        vis[u] = true;
        pq.pop();
        for (auto [v, cost] : adj[u]){
            if (dist[v] > dist[u] + cost)
                pq.push({dist[v] = dist[u] + cost, v}), par[v] = u;
                
        }
    }
    vis.assign(n, 0);

    while (pq.size()){
        int u; ll w;
        tie (w, u) = pq.top();
        if (vis[u]) continue;
        vis[u] = true;
        pq.pop();
        for (auto [v, cost] : adj[u]){
            if (dist2[v] > dist2[u] + cost && par[v] != u)
                pq.push({dist2[v] = dist2[u] + cost, v});
                
        }
    }
    
    return dist2[0];
}


# Verdict Execution time Memory Grader output
1 Execution timed out 2092 ms 4440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2092 ms 4440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2092 ms 4440 KB Time limit exceeded
2 Halted 0 ms 0 KB -