제출 #583281

#제출 시각아이디문제언어결과실행 시간메모리
583281alirezasamimi100Escape Route (JOI21_escape_route)C++17
5 / 100
9053 ms111948 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...