# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1118370 | alexdd | Magic Tree (CEOI19_magictree) | C++17 | 129 ms | 35912 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;
#define int long long
const int INF = 1e9;
int n,m,k;
vector<int> con[100005];
int parent[100005];
int d[100005],w[100005];
map<int,int> dp[100005];
void dfs(int nod)
{
int maxc=-1,heavy=-1;
for(int adj:con[nod])
{
dfs(adj);
if((int)dp[adj].size() > maxc)
maxc = dp[adj].size(), heavy = adj;
}
if(heavy!=-1) swap(dp[nod], dp[heavy]);
for(int adj:con[nod])
{
if(adj==heavy)
continue;
for(auto it:dp[adj])
dp[nod][it.first] += it.second;
}
if(w[nod] > 0)
{
dp[nod][d[nod]] += w[nod];
auto it = dp[nod].upper_bound(d[nod]);
# | 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... |