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>
using namespace std;
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define LINF 1023456789123456789
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,int> li;
typedef vector<int> vi;
typedef vector<ll> vll;
struct edge{int v;ll l,c;};
vector<edge> AL[100];
ll d[100];
vll ans;
priority_queue<li,vector<li>,greater<li>> pq;
vll calculate_necessary_time(int N, int M, ll S, int Q, vi A, vi B, vll L, vll C, vi U, vi V, vll T) {
for(int i=0;i<M;++i){
AL[A[i]].pb({B[i],L[i],C[i]});
AL[B[i]].pb({A[i],L[i],C[i]});
}
for(int i=0;i<Q;++i){
for(int j=0;j<N;++j)d[j]=LINF;
pq.push({T[i],U[i]});
while(!pq.empty()){
ll t;int u;tie(t,u)=pq.top();pq.pop();
if(t>d[u])continue;
for(edge e:AL[u]){
ll reach;
if(t%S<=e.c-e.l){
reach=t+e.l;
}
else{
reach=(t/S+1)*S+e.l;
}
if(d[e.v]<=reach)continue;
d[e.v]=reach;
pq.push({d[e.v],e.v});
}
}
ans.pb(d[V[i]]-T[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... |