Submission #731817

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7318172023-04-28 03:34:08TrunktyRoadside Advertisements (NOI17_roadsideadverts)C++14
100 / 100
253 ms32964 KiB
#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];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...