Submission #753577

# Submission time Handle Problem Language Result Execution time Memory
753577 2023-06-05T14:14:19 Z nonono Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
0 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;
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:32:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   32 |             for(auto [v, w] : adj[u]){
      |                      ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -