# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
922884 | ttamx | Magic Tree (CEOI19_magictree) | C++14 | 97 ms | 32848 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>
using namespace std;
using ll = long long;
const int N=1e5+5;
int n,m,k;
vector<int> adj[N];
int d[N],w[N];
map<int,ll> dp[N];
void dfs(int u){
for(auto v:adj[u]){
dfs(v);
if(dp[v].size()>dp[u].size())swap(dp[u],dp[v]);
for(auto [x,y]:dp[v])dp[u][x]+=y;
dp[v].clear();
}
if(w[u]){
dp[u][d[u]]+=w[u];
int tmp=w[u];
for(auto it=next(dp[u].find(d[u]));it!=dp[u].end();){
if(tmp>=it->second){
tmp-=it->second;
it=dp[u].erase(it);
}else{
it->second-=tmp;
break;
Compilation message (stderr)
# | 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... |