You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
901 B

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const int N = 150010, M = N << 1;
int st[N];
int dis[N];
int n, m;
int e[M], h[N], idx, w[M], ne[M];
void add(int a,int b,int c){
e[idx] = b, ne[idx] = h[a], w[idx] = c, h[a] = idx++;
}
int dijkstra(){
memset(dis, 0x3f, sizeof dis);
dis[1] = 0;
priority_queue<PII, vector<PII>, greater<PII>> q;
q.push({0, 1});
while(q.size()){
PII t = q.top();
q.pop();
int d = t.first;
int u = t.second;
if(!st[u]){
st[u] = 1;
for (int i = h[u]; ~i;i=ne[i]){
int v = e[i];
if(dis[v]>d+w[i]){
dis[v] = d + w[i];
q.push({dis[v], v});
}
}
}
}
}
int main() {
return 0;
}