# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168524 | achibasadzishvili | Evacuation plan (IZhO18_plan) | C++14 | 0 ms | 0 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.
nclude <bits/stdc++.h>
#define ll int
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
ll k,n,m,qq,d[100005],p[100005],c[100005],ans[100005],las,fix[100005];
ll qu[100005],sz[100005];
vector<ll>vec[100005];
vector<pair<ll,ll> >v[100005],q[100005];
set<pair<ll,ll> >st;
ll find(ll x){
if(p[x] == x)return x;
return p[x] = find(p[x]);
}
void join(ll x,ll y){
x = find(x);
y = find(y);
if(x == y)return;
if(sz[x] < sz[y])swap(x , y);
qu[x] += qu[y];
sz[x] += sz[y];
for(int i=0; i<q[y].size(); i++){
if(find(q[y][i].f) == x)
ans[q[y][i].s] = min(ans[q[y][i].s] , las);
q[x].pb(q[y][i]);
}
for(int i=0; i<vec[y].size(); i++){
vec[x].pb(vec[y][i]);