# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
923209 | golions | Magic Tree (CEOI19_magictree) | C++17 | 101 ms | 33476 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>
//problem from https://usaco.guide/adv/slope-trick?lang=cpp
using namespace std;
vector<vector<int>> adj;
vector<pair<int,long long>> fruits;
map<int,long long> dfs(int v, int p){
map<int,long long> ret;
for(int nei : adj[v]){
if(nei == p) continue;
auto neimap = dfs(nei,v);
if(ret.size() < neimap.size()) swap(ret,neimap);
for(auto [d,w] : neimap){
ret[d] += w;
}
}
if(fruits[v].first != -1){
//add this fruit
long long tot = fruits[v].second;
ret[fruits[v].first] += tot;
int cur = fruits[v].first;
//this will loop O(N) times amortized (every fruit will be removed once)
# | 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... |
# | 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... |