Submission #753574

# Submission time Handle Problem Language Result Execution time Memory
753574 2023-06-05T14:10:23 Z nonono Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
1 ms 212 KB
#include "crocodile.h"
#include "bits/stdc++.h"
using namespace std;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    vector<pair<int, int>> adj[N];
    
    for(int i = 0; i < M; i ++){
        adj[R[i][0]].push_back({R[i][1], L[i]});
        adj[R[i][1]].push_back({R[i][0], L[i]});
    }
    
    int T[N];
    for(int i = 0; i < N; i ++) T[i] = 0;
    
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    
    for(int i = 0; i < K; i ++){
        pq.push({0, P[i]});
        T[P[i]] = 2;
    }
    
    while(!pq.empty()){
        int u = pq.top().second;
        int du = pq.top().first;
        pq.pop();
        
        T[u] ++ ;
        if(T[u] == 2){
            if(!u) return du;
            
            for(auto [v, w] : adj[u]){
                if(T[v] >= 2) continue ;
                pq.push({du + w, v});
            }
        }
    }
    
    return -1;
}



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