#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
64972 KB |
Output is correct |
2 |
Correct |
35 ms |
65024 KB |
Output is correct |
3 |
Correct |
43 ms |
65076 KB |
Output is correct |
4 |
Correct |
29 ms |
65028 KB |
Output is correct |
5 |
Correct |
34 ms |
65024 KB |
Output is correct |
6 |
Correct |
30 ms |
64972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
9082 ms |
112228 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
64972 KB |
Output is correct |
2 |
Correct |
35 ms |
65024 KB |
Output is correct |
3 |
Correct |
43 ms |
65076 KB |
Output is correct |
4 |
Correct |
29 ms |
65028 KB |
Output is correct |
5 |
Correct |
34 ms |
65024 KB |
Output is correct |
6 |
Correct |
30 ms |
64972 KB |
Output is correct |
7 |
Execution timed out |
9082 ms |
112228 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
64972 KB |
Output is correct |
2 |
Correct |
35 ms |
65024 KB |
Output is correct |
3 |
Correct |
43 ms |
65076 KB |
Output is correct |
4 |
Correct |
29 ms |
65028 KB |
Output is correct |
5 |
Correct |
34 ms |
65024 KB |
Output is correct |
6 |
Correct |
30 ms |
64972 KB |
Output is correct |
7 |
Execution timed out |
9082 ms |
112228 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
64972 KB |
Output is correct |
2 |
Correct |
35 ms |
65024 KB |
Output is correct |
3 |
Correct |
43 ms |
65076 KB |
Output is correct |
4 |
Correct |
29 ms |
65028 KB |
Output is correct |
5 |
Correct |
34 ms |
65024 KB |
Output is correct |
6 |
Correct |
30 ms |
64972 KB |
Output is correct |
7 |
Execution timed out |
9082 ms |
112228 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |