# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
854540 | MilosMilutinovic | Fireworks (APIO16_fireworks) | C++14 | 275 ms | 103292 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>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int readint(){
int x=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,m;
vector<pii> g[300005];
multiset<ll> pts[300005];
void dfs(int x,int w){
for(auto&p:g[x]) dfs(p.fi,p.se);
int ch=-1;
for(auto&p:g[x]) if(ch==-1||(int)pts[ch].size()<(int)pts[p.fi].size()) ch=p.fi;
if(ch!=-1) swap(pts[x],pts[ch]);
for(auto&p:g[x]) if(p.fi!=ch) for(ll pt:pts[p.fi]) pts[x].insert(pt);
for(int i=0;i<(int)g[x].size()-1;i++) pts[x].erase(prev(pts[x].end()));
# | 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... |