HITACHI2020 C. ThREE
Difficulty:2013
問題
解法
実装
code:cpp
bool solve(){
LL(n);
vector<vector<ll>>g(n);
rep(i,n-1){
LL(a,b);a--,b--;
}
vector<ll>dist(n,INF);
queue<ll>q;
q.push(0);
while(q.size()){
ll pos = q.front();q.pop();
if(chmin(distto,distpos+1)){ q.push(to);
}
}
}
vector<vector<ll>>vec(2);
rep(i,n){
vec[disti%2].push_back(i); }
vector<ll>ans(n,-1);
vector<vector<ll>>cnt(3);
rep(i,1,n+1){
}
}
}
ll i{};
while(cnt0.size()&&i<vec1.size()){ ans[vec1i++] = cnt0.back(); }
while(cnt1.size()&&i<vec1.size()){ ans[vec1i++] = cnt1.back(); }
while(cnt2.size()&&i<vec1.size()){ ans[vec1i++] = cnt2.back(); }
}
else{
ll l{},r{};
while(cnt1.size()&&l<vec1.size()){ ans[vec1l++] = cnt1.back(); }
while(cnt0.size()&&l<vec1.size()){ ans[vec1l++] = cnt0.back(); }
while(cnt2.size()&&r<vec0.size()){ ans[vec0r++] = cnt2.back(); }
while(cnt0.size()&&r<vec0.size()){ ans[vec0r++] = cnt0.back(); }
}
O(ans);
return false;
}