Submission #583276

#TimeUsernameProblemLanguageResultExecution timeMemory
583276alirezasamimi100Escape Route (JOI21_escape_route)C++17
5 / 100
9025 ms111948 KiB
#include "escape_route.h" #include <bits/stdc++.h> #define pb push_back #define F first #define S second using namespace std; using ll = long long int; using pll = pair<ll, ll>; using pii = pair<int, int>; vector<ll> calculate_necessary_time(int N, int M, ll S, int Q, vector<int> A, vector<int> B, vector<ll> L, vector<ll> C, vector<int> U, vector<int> V, vector<ll> T) { vector<pair<int, int>> adj[N]; vector<ll> ans(Q); priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq; for(int i = 0; i < M; i++){ adj[A[i]].pb({B[i], i}); adj[B[i]].pb({A[i], i}); } for(int i = 0; i < Q; i++){ ll d[N]; memset(d, 63, sizeof d); d[U[i]] = T[i]; pq.push({T[i], U[i]}); while(!pq.empty()){ ll x = pq.top().F, y = x % S; int v = pq.top().S; pq.pop(); if(x != d[v]) continue; for(auto [u, i] : adj[v]){ ll w = L[i], c = C[i]; if(y + w > c) w += S - y; if(d[u] > x + w){ d[u] = x + w; pq.push({d[u], u}); } } } ans[i] = d[V[i]] - d[U[i]]; } return ans; }
#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...