# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1171410 | aguss | Valley (BOI19_valley) | C++20 | 88 ms | 24604 KiB |
#include <bits/stdc++.h>
#define raya() cout << endl << "====================================" << endl
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbgv(v) cerr << #v << ": "; for(auto &el : v) cerr << el << " "; cerr << '\n';
#define INFINITY 1e8
using namespace std;
using ll = long long;
int n, s, q, e;
int lg = 5;
vector<vector<pair<int, int>>> arr;
vector<vector<int>> up, min_shop;
vector<int> dp, depth, distances;
unordered_set<int> shops;
int lca(int a, int b);
int calc_distance(int a, int b){
return distances[a] + distances[b] - 2 * distances[lca(a, b)];
}
void dfs_min_shop(int curr, int prev, int weight){
min_shop[curr][0] = min(dp[curr], dp[prev] + weight);
for(int i = 1; i <= lg; i++){
min_shop[curr][i] = min({
min_shop[up[curr][i - 1]][i - 1] + calc_distance(curr, up[curr][i - 1]),
min_shop[curr][i - 1]
});
}
for(auto &x : arr[curr]){
Compilation message (stderr)
# | 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... |