# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
731817 | Trunkty | Roadside Advertisements (NOI17_roadsideadverts) | C++14 | 253 ms | 32964 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/extc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n,q;
vector<vector<int>> roads[50005];
int jump[50005][21],dist[50005][21],dep[50005];
int curr=0;
void dfs(int x, int p){
for(vector<int> i:roads[x]){
if(i[0]!=p){
jump[i[0]][0] = x;
dist[i[0]][0] = i[1];
dep[i[0]] = dep[x]+1;
dfs(i[0],x);
}
}
}
int lca(int a, int b){
curr = 0;
if(dep[a]>dep[b]){
swap(a,b);
}
for(int j=20;j>=0;j--){
if(dep[b]-(1<<j)>=dep[a]){
curr += dist[b][j];
b = jump[b][j];
# | 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... |