Submission #935659

#TimeUsernameProblemLanguageResultExecution timeMemory
935659PanndaEscape Route (JOI21_escape_route)C++17
0 / 100
9093 ms749496 KiB
#include "escape_route.h" #include <bits/stdc++.h> using namespace std; vector<long long> calculate_necessary_time(int n, int m, long long S, int q, vector<int> A, vector<int> B, vector<long long> L, vector<long long> C, vector<int> U, vector<int> V, vector<long long> T) { const long long INF = 9e18; vector<vector<pair<int, int>>> adj(n); for (int i = 0; i < m; i++) { int u = A[i]; int v = B[i]; adj[u].push_back({v, i}); adj[v].push_back({u, i}); } vector<long long> res(q); for (int i = 0; i < q; i++) { map<pair<int, long long>, long long> dist; priority_queue<pair<long long, pair<int, long long>>, vector<pair<long long, pair<int, long long>>>, greater<>> pq; pq.push({dist[{U[i], T[i]}] = 0, make_pair(U[i], T[i])}); while (!pq.empty()) { auto [d, ut] = pq.top(); pq.pop(); if (d != dist[ut]) continue; auto [u, t] = ut; for (auto [v, i] : adj[u]) { if (t <= C[i] - L[i]) { long long tt = t + L[i]; if (!dist.count({v, tt}) || dist[{v, tt}] > d + L[i]) { pq.push({dist[{v, tt}] = d + L[i], make_pair(v, tt)}); } } } long long tt = 0; if (!dist.count({u, tt}) || dist[{u, tt}] > d + S - t) { pq.push({dist[{u, tt}] = d + S - t, make_pair(u, tt)}); } } long long mn = INF; for (auto [ut, d] : dist) { if (ut.first == V[i]) { mn = min(mn, d); } } res[i] = mn; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...