This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2001;
int par[MAX];
int find(int u){
if(par[u] < 0) return u;
return par[u] = find(par[u]);
}
bool unite(int u, int v){
u = find(u), v = find(v);
if(u == v) return false;
if(par[u] > par[v]) swap(u, v);
par[u] += par[v];
par[v] = u;
return true;
}
int min_cardinality(int N) {
memset(par, -1, sizeof(par));
for(int i = 0; i < N; i++){
for(int j = i + 1; j < N; j++){
move_inside(i);
move_inside(j);
if(press_button() == 2) unite(i, j);
move_outside(i);
move_outside(j);
}
}
int ans = N + 1;
for(int i = 0; i < N; i++){
ans = min(ans, -par[find(i)]);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |