#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define pii pair<int, int>
#define siz 100000/10000
#define inf 10e17
#define int long long
int dist [siz];
int secondDist [siz];
bool proc [siz];
struct Compare {
bool operator()(int a, int b) {
return (secondDist[a] > secondDist[b]);
}
};
int travel_plan(int nbNodes, int nbEdges, vector<vector<int>> corridors, vector<int> travelTime, int nbExits, vector<int> exits) {
vector<vector<pii>> graph(nbNodes);
for (int i = 0; i < nbEdges; i++) {
graph[corridors[i][0]].push_back(pii(corridors[i][1], travelTime[i]));
graph[corridors[i][1]].push_back(pii(corridors[i][0], travelTime[i]));
}
for (int i = 0; i < nbNodes; i++) {
dist[i] = inf;
secondDist[i] = inf;
proc[i] = false;
}
priority_queue<int, vector<int>, Compare> q;
for (int i : exits) {
q.push(i);
dist[i] = 0;
secondDist[i] = 0;
}
while (!q.empty()) {
int curNode = q.top();
q.pop();
if (proc[curNode]) continue;
proc[curNode] = true;
for (pii newEdge : graph[curNode]) {
int newNode = newEdge.first;
int newWeight = newEdge.second;
int newDist = secondDist[curNode]+newWeight;
if (proc[newNode] or newDist > secondDist[newNode]) continue;
if (newDist <= dist[newNode]) {
secondDist[newNode] = dist[newNode];
dist[newNode] = newDist;
}
else if (newDist <= secondDist[newNode]) {
secondDist[newNode] = newDist;
}
else {
cerr << "ISSUE-1";
}
q.push(newNode);
}
}
int maxDist = 0;
for (int i = 0; i < nbNodes; i++) {
maxDist = max(maxDist, secondDist[i]);
}
return maxDist;
}
int32_t main() {
int nbNodes, nbEdges;
cin >> nbNodes >> nbEdges; // simul
vector<vector<int>> corridors(nbEdges, vector<int>(2));
for (int i = 0; i < nbEdges; i++) cin >> corridors[i][0] >> corridors[i][1]; // simul
vector<int> travelTime(nbEdges);
for (int i = 0; i < nbEdges; i++) cin >> travelTime[i]; // simul
int nbExits;
cin >> nbExits;
vector<int> exits(nbExits);
for (int i = 0; i < nbExits; i++) cin >> exits[i];
cout << travel_plan(nbNodes, nbEdges, corridors, travelTime, nbExits, exits);
}
Compilation message
/tmp/ccyeKzn5.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccPEgyJ9.o:crocodile.cpp:(.text.startup+0x0): first defined here
/tmp/ccyeKzn5.o: In function `main':
grader.cpp:(.text.startup+0x32): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status