#include<bits/stdc++.h>
#include "escape_route.h"
using namespace std;
typedef long long llint;
typedef pair <llint, llint> pi;
typedef vector <int> Vi;
typedef vector <llint> vi;
const int MAXN = 91;
const int MAXM = 91 * 91;
const llint INF = 1000000000000000000LL;
llint n, m, s, q, br;
llint len[MAXM], c[MAXN];
llint path[MAXN][MAXN], bio[MAXN][MAXN];
vector <pi> v[MAXN];
void dijkstra (int root, llint d) {
for (int i = 0; i < n; i++) {
path[root][i] = INF;
bio[root][i] = 0;
}
path[root][root] = d;
for (int i = 0; i < n; i++) {
llint mn = INF, ind = -1;
for (int j = 0; j < n; j++) {
if (bio[root][j] == 0 && path[root][j] < mn) {
mn = path[root][j];
ind = j;
}
}
bio[root][ind] = 1;
for (auto pp : v[ind]) {
int sus = pp.first, e = pp.second;
llint novi = path[root][ind] + len[e];
if (path[root][ind] % s <= c[e] - len[e]) {
path[root][sus] = min(path[root][sus], novi);
}
novi += s - path[root][ind] % s;
path[root][sus] = min(path[root][sus], novi);
}
}
}
vi calculate_necessary_time (int N, int M, llint S, int Q,
Vi A, Vi B, vi L, vi C, Vi U, Vi V, vi T) {
n = N; m = M; s = S; q = Q;
for (int i = 0; i < m; i++) {
len[i] = L[i];
c[i] = C[i];
v[A[i]].push_back({B[i], i});
v[B[i]].push_back({A[i], i});
}
vi sol;
for (int i = 0; i < q; i++) {
dijkstra(U[i], T[i]);
sol.push_back(path[U[i]][V[i]] - T[i]);
}
return sol;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
64964 KB |
Output is correct |
2 |
Incorrect |
48 ms |
65040 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
9092 ms |
111996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
64964 KB |
Output is correct |
2 |
Incorrect |
48 ms |
65040 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
64964 KB |
Output is correct |
2 |
Incorrect |
48 ms |
65040 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
64964 KB |
Output is correct |
2 |
Incorrect |
48 ms |
65040 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |