This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "escape_route.h"
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define debug(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N = 92;
int n, m;
ll S;
vi A, B;
vl L, C;
vector<int> G[N];
ll dis[N], mk[N];
void Djik(int src, ll st){
memset(dis, 31, sizeof dis);
memset(mk, 0, sizeof mk);
dis[src] = st;
int adj;
ll w;
for(int _ = 0; _ < n; _++){
int idx = -1;
for(int i = 0; i < n; i++) if(!mk[i]) idx = i;
if(idx == -1) continue;
for(int i = 0; i < n; i++) if(!mk[i] && dis[i] < dis[idx]) idx = i;
mk[idx] = 1;
for(auto e : G[idx]){
adj = A[e] ^ B[e] ^ idx;
if(dis[idx] % S <= C[e] - L[e])
w = dis[idx] + L[e];
else
w = dis[idx] + (S - (dis[idx] % S)) + L[e];
if(w < dis[adj])
dis[adj] = w;
}
}
}
vl calculate_necessary_time(int _n, int _m, ll _S, int Q, vi _A, vi _B, vl _L, vl _C, vi _U, vi _V, vl _T) {
n = _n; m = _m; S = _S;
A = _A; B = _B; L = _L; C = _C;
for(int i = 0; i < m; i++)
G[A[i]].pb(i), G[B[i]].pb(i);
vl ANS;
for(int i = 0; i < Q; i++){
Djik(_U[i], _T[i]);
ANS.pb(dis[_V[i]] - _T[i]);
}
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... |