| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1080000 | LittleOrange | 드문 곤충 (IOI22_insects) | C++17 | 256 ms | 596 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 "insects.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
struct dsu{
vector<ll> p;
dsu(ll n):p(n,-1){}
ll g(ll i){
return p[i]<0?i:p[i] = g(p[i]);
}
bool m(ll a, ll b){
a = g(a),b = g(b);
if (a==b) return false;
if(p[a]>p[b]) swap(a,b);
p[a] += p[b];
p[b] = a;
return true;
}
};
int min_cardinality(int n) {
mt19937_64 mt(random_device{}());
vector<ll> a(n);
iota(a.begin(),a.end(),0);
dsu d(n);
ll run = 1;
while(run){
run = 0;
shuffle(a.begin(),a.end(),mt);
vector<ll> v;
for(ll i : a) if(d.p[i]<0) v.push_back(i);
ll l = 0;
for(ll i = 0;i<v.size();i++){
move_inside(v[i]);
if (i>0&&press_button()>1){
do{
move_outside(v[l++]);
}while(press_button()>1);
d.m(v[l-1],v[i]);
run = 1;
}
}
while(l<v.size())move_outside(v[l++]);
}
ll ans = -n;
for(ll i : d.p) if(i<0)ans = max(ans,i);
return -ans;
}
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... | ||||
