이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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>;
const ll INF = 4e18;
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);
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];
bool f[N];
memset(d, 63, sizeof d);
memset(f, 0, sizeof f);
d[U[i]] = T[i];
while(true){
int v = -1;
for(int i = 0; i < N; i++){
if(!f[i] && (v == -1 || d[i] < d[v])) v = i;
}
if(v == -1) break;
f[v] = 1;
ll x = d[v], y = x % S;
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;
}
}
}
ans[i] = d[V[i]] - d[U[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... |