Submission #922884

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9228842024-02-06 08:48:29ttamxMagic Tree (CEOI19_magictree)C++14
100 / 100
97 ms32848 KiB
#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;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

magictree.cpp: In function 'void dfs(int)':
magictree.cpp:18:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   18 |         for(auto [x,y]:dp[v])dp[u][x]+=y;
      |                  ^
magictree.cpp: In function 'int main()':
magictree.cpp:50:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   50 |     for(auto [x,y]:dp[1])ans+=y;
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...