#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 time |
Memory |
Grader output |
1 |
Correct |
28 ms |
64996 KB |
Output is correct |
2 |
Correct |
44 ms |
64940 KB |
Output is correct |
3 |
Correct |
48 ms |
64976 KB |
Output is correct |
4 |
Correct |
26 ms |
65008 KB |
Output is correct |
5 |
Correct |
33 ms |
65068 KB |
Output is correct |
6 |
Correct |
31 ms |
64980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
9025 ms |
111948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
64996 KB |
Output is correct |
2 |
Correct |
44 ms |
64940 KB |
Output is correct |
3 |
Correct |
48 ms |
64976 KB |
Output is correct |
4 |
Correct |
26 ms |
65008 KB |
Output is correct |
5 |
Correct |
33 ms |
65068 KB |
Output is correct |
6 |
Correct |
31 ms |
64980 KB |
Output is correct |
7 |
Execution timed out |
9025 ms |
111948 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
64996 KB |
Output is correct |
2 |
Correct |
44 ms |
64940 KB |
Output is correct |
3 |
Correct |
48 ms |
64976 KB |
Output is correct |
4 |
Correct |
26 ms |
65008 KB |
Output is correct |
5 |
Correct |
33 ms |
65068 KB |
Output is correct |
6 |
Correct |
31 ms |
64980 KB |
Output is correct |
7 |
Execution timed out |
9025 ms |
111948 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
64996 KB |
Output is correct |
2 |
Correct |
44 ms |
64940 KB |
Output is correct |
3 |
Correct |
48 ms |
64976 KB |
Output is correct |
4 |
Correct |
26 ms |
65008 KB |
Output is correct |
5 |
Correct |
33 ms |
65068 KB |
Output is correct |
6 |
Correct |
31 ms |
64980 KB |
Output is correct |
7 |
Execution timed out |
9025 ms |
111948 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |