# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
923209 | golions | Magic Tree (CEOI19_magictree) | C++17 | 101 ms | 33476 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |