From 78386dd74b1e8ad20b56682a59c0edd507d38824 Mon Sep 17 00:00:00 2001 From: Ta180m Date: Thu, 30 Apr 2020 22:11:51 -0500 Subject: Create pump.cpp --- 2019/December/pump.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 2019/December/pump.cpp diff --git a/2019/December/pump.cpp b/2019/December/pump.cpp new file mode 100644 index 0000000..20beb76 --- /dev/null +++ b/2019/December/pump.cpp @@ -0,0 +1,46 @@ +#include +#define f first +#define s second +using namespace std; +typedef long long ll; +typedef pair ii; +typedef vector vi; +typedef vector vii; +constexpr int INF = 1e9; + +vector> G[1001]; + +int main() { + ifstream cin("pump.in"); + ofstream cout("pump.out"); + + int N, M; + cin >> N >> M; + while (M--) { + int a, b, c, f; + cin >> a >> b >> c >> f; + G[a].emplace_back(b, ii(c, f)); + G[b].emplace_back(a, ii(c, f)); + } + + int ans = 0; + for (int i = 1; i <= 1000; ++i) { + vi dist(N + 1, INF); + dist[1] = 0; + priority_queue> pq; + pq.emplace(0, 1); + while (!pq.empty()) { + int d = pq.top().f, u = pq.top().s; + pq.pop(); + if (d > dist[u]) continue; + for (auto& v : G[u]) { + if (v.s.s >= i && d + v.s.f < dist[v.f]) { + dist[v.f] = d + v.s.f; + pq.emplace(dist[v.f], v.f); + } + } + } + ans = max((int)1e6 * i / dist[N], ans); + } + cout << ans << '\n'; +} -- cgit v1.2.3-70-g09d2