# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1152228 | jnjwnwnw | Roadside Advertisements (NOI17_roadsideadverts) | C++17 | 102 ms | 15256 KiB |
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
#define fff(i, a, b) for(int i = a; i < b; i++)
#define fffm(i, a, b) for(int i = a; i > b; i--)
#define N 50004
#define LGN 18
ll anc[N][LGN], sm[N], dep[N];
int n, q;
vector<pair<int, ll>> adj[N];
void dfs1(int nod, int frm, int cum_sm, int dpth){
sm[nod] = cum_sm;
anc[nod][0] = frm;
dep[nod] = dpth;
for(auto [a, b]: adj[nod]){
if (a != frm){
dfs1(a, nod, cum_sm+b, dpth+1);
}
}
}
void lca_init(){
fff(j, 1, LGN){
fff(i, 0, n){
anc[i][j] = anc[anc[i][j-1]][j-1];
# | 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... |