#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
64980 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
9080 ms |
111944 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
64980 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
64980 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
64980 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |