이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define OVL(v,s) for(auto x:v) cout<<x<<s;cout<<endl;
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pb push_back
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
#define endl "\n"
#define mod 1000000007
const ll INF=1e18;
const int MAXN=1e5+100;
int par[MAXN];
int sz[MAXN];
void make_set(){
for(int i=0;i<MAXN;i++) par[i]=i,sz[i]=1;
}
int find(int node){
if(node==par[node]) return node;
return par[node]=find(par[node]);
}
int min_cardinality(int N) {
make_set();
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
if(!(i^j)) continue;
move_inside(i);
move_inside(j);
int x=press_button();
if(x==2){
//same element
int jj=find(j);
int ii=find(i);
if(sz[ii]<sz[jj]) swap(ii,jj);
par[jj]=ii;
sz[ii]+=sz[jj];
}
move_outside(i);
move_outside(j);
}
}
set<int> roots;
for(int i=0;i<N;i++) roots.insert(find(i));
ll ans=INF;
for(auto x:roots) ans=min(ans,(ll)sz[x]);
return (int)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... |