# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1072820 | PenguinsAreCute | Building Skyscrapers (CEOI19_skyscrapers) | C++17 | 3532 ms | 113552 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;
using i2 = pair<int,int>;
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(v) begin(v),end(v)
#define sz(v) int(v.size())
namespace ufds {
int par[1200005], sz[1200005], spec;
vector<int> child[1200005]; // "literally a child"
vector<int> toUp;
void init(int _spec) {
iota(par,par+1200005,0);
fill(sz,sz+1200005,0);
for(int i=0;i<1200005;i++) child[i]={i};
spec = _spec;
toUp = {spec};
}
int onion(int x) {return par[x]=(par[x]==x?x:onion(par[x]));}
void unite(int x, int y) {
x = onion(x); y = onion(y);
if(sz[x]>sz[y]) swap(x,y);
if(x==y) return;
if(x==onion(spec)) for(auto i: child[y]) toUp.push_back(i);
if(y==onion(spec)) for(auto i: child[x]) toUp.push_back(i);
for(auto i: child[x]) child[y].push_back(i);
sz[y]+=sz[x]; par[x]=y;
Compilation message (stderr)
# | 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... |