이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "escape_route.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<pair<pair<int,int>,int> > adjl[99];
std::vector<long long> calculate_necessary_time(
int32_t N, int32_t M, long long S, int32_t Q, std::vector<int32_t> A, std::vector<int32_t> B,
std::vector<long long> L, std::vector<long long> C, std::vector<int32_t> U,
std::vector<int32_t> V, std::vector<long long> T) {
for (int x = 0; x<M; x++){
if (L[x]>C[x]) continue;
adjl[A[x]].push_back({{L[x],C[x]},B[x]});
adjl[B[x]].push_back({{L[x],C[x]},A[x]});
}
vector<int> ans;
for (int x = 0; x<Q; x++){
int dist[99];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
for (int y = 0; y<N; y++){
dist[y] = 999999999999999999LL;
}
dist[U[x]] = T[x];
pq.push({dist[U[x]],U[x]});
while (!pq.empty()){
int node = pq.top().second;
int d = pq.top().first;
pq.pop();
if (d>dist[node]) continue;
// printf("node %lld dist %lld\n",node,d);
for (auto x : adjl[node]){
int nxd;
if (d%S+x.first.first>x.first.second){
nxd = ((d/S)+1)*S+x.first.first;
}else{
nxd = d+x.first.first;
}
if (nxd<dist[x.second]){
dist[x.second] = nxd;
pq.push({nxd,x.second});
}
}
}
ans.push_back(dist[V[x]]-T[x]);
}
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... |