# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
876020 | Regulus | Escape Route (JOI21_escape_route) | C++17 | 0 ms | 0 KiB |
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 <bits/stdc++.h> // pA
#include "escape_route.h"
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using ppl = pair<pll, ll>;
const int N = 2e5+5;
const int INF = 2e9;
pll dis[N];
vector<ll> ans;
vector<pll> g[N];
priority_queue<ppl, vector<ppl>, greater<ppl> > pq;
vector<ll> calculate_necessary_time(int n, int m, ll s, int Q, vector<int> A, vector<int> B,
vector<int> L, vector<int> C, vector<int> U, vector<int> V, vector<int> T)
{
int i, j;
for (i=0; i < m; ++i) g[A[i]].pb(B[i], i), g[B[i]].pb(A[i], i);
for (int t=0; t < Q; ++t)
{
while (!pq.empty()) pq.pop();
for (i=0; i < n; ++i) dis[i] = {INF, INF};
dis[U[t]] = {0, 0}, pq.push({pll{0, 0}, U[t]});
while (!pq.empty())
{
int x = pq.top().S;
pq.pop();
for (auto p : g[x])
{
ll v = p.F, id = p.S;
pll tmp = dis[x];
tmp.S += L[p.S];
if (tmp.S > C[id]) ++tmp.F, tmp.S = 0;
if (tmp < dis[v])
{
dis[v] = tmp, pq.push({dis[v], v});
}
}
}
ans.pb(dis[V[t]].F*s + dis[V[t]].S);
}
return ans;
}