This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 - x;
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |