#include <bits/stdc++.h>
using namespace std;

void mincammino(int N, int M, vector<int> X, vector<int> Y, vector<int> P, vector<long long>& D) {
    fill(D.begin(), D.end(), LLONG_MAX);
    priority_queue<pair<long long, int>> pq = {};
    pq.push({0, 0});
    vector<vector<pair<int, long long>>> adj(N);
    for(int i = 0; i < M; i++){
        adj[X[i]].push_back({Y[i], P[i]});
    }
    // codice...
    set<int> vis = {};
    int act;
    long long dis;
    while(!pq.empty()){
        act = pq.top().second;
        dis = pq.top().first;
        pq.pop();
        D[act] = min(D[act], dis);
        for(int i = 0; i < adj[act].size(); i++){
            if(vis.count(adj[act][i].first) == 0){
                vis.insert(adj[act][i].first);
                pq.push({D[adj[act][i].first] + adj[act][i].second, adj[act][i].first});
            }
        }
    }
    for(int i = 0; i < D.size(); i++) if(D[i] == LLONG_MAX) D[i] == -1; 
}
