0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-14 03:18:48 +00:00
OI-codes/Luogu/P3063/P3063.cpp

52 lines
1014 B
C++
Raw Normal View History

#include <bits/stdc++.h>
using namespace std;
struct node {
int v, l, c;
node() {}
2022-05-20 01:23:27 +00:00
node(int _v, int _l, int _c)
2022-06-01 01:45:41 +00:00
: v(_v),
l(_l),
c(_c) {}
};
int n, m, x, u, v, l, c, tot, a[505], dist[505], ans = 0x3f3f3f3f;
vector<node> g[505];
void spfa(int x) {
queue<int> q;
memset(dist, 0x3f, sizeof(dist));
dist[1] = 0;
q.push(1);
while (!q.empty()) {
auto u = q.front();
q.pop();
for (auto i : g[u]) {
if (dist[i.v] > dist[u] + i.l && i.c >= x) {
dist[i.v] = dist[u] + i.l;
q.push(i.v);
}
}
}
}
int main() {
cin >> n >> m >> x;
for (int i = 0; i < m; i++) {
cin >> u >> v >> l >> c;
g[u].push_back(node(v, l, c));
g[v].push_back(node(u, l, c));
a[i] = c;
}
sort(a, a + m);
for (int i = 0; i < m; i++) {
spfa(a[i]);
ans = min(ans, dist[n] + x / a[i]);
}
cout << ans << endl;
return 0;
}