// @EXPECTED_RESULTS@: WRONG_ANSWER, TIME_LIMIT_EXCEEDED /* * Loops over all nodes and adds an edge from that node to destination node with cost of group ticket */ #include #include #include #include using namespace std; #define pii pair struct E{ int node; int weight; bool operator<(const E& a) const { return weight > a.weight; } }; int dijkstra(vector> & adj, int s){ int n = adj.size(); vector dist(n, INT_MAX); vector visited(n, 0); priority_queue q; q.push({s, 0}); dist[s] = 0; while(!q.empty()){ int u = q.top().node; int d = q.top().weight; q.pop(); if(u == 0){ return d; } if(!visited[u]){ visited[u] = true; for(auto edge: adj[u]){ if(d + edge.weight < dist[edge.node]){ dist[edge.node] = d + edge.weight; q.push({edge.node, d + edge.weight}); } } } } return INT_MAX; } int main(){ int n, m, p, g; cin >> n >> m >> p >> g; vector v(p); for(int i=0;i > v[i]; v[i]--; } vector> adj(n, vector()); for(int i=0; i> a >> b >> c; a--; b--; adj[a].push_back({b, c}); adj[b].push_back({a, c}); } int best_cost = INT_MAX; for(int i=0; i