Submission #1135042

#TimeUsernameProblemLanguageResultExecution timeMemory
1135042Saul0906Rarest Insects (IOI22_insects)C++20
0 / 100
50 ms464 KiB
#include "insects.h" #include <vector> #include <bits/stdc++.h> #define rep(a,b,c) for(ll a=b; a<c; a++) #define repr(a,b,c) for(ll a=b-1; a>c-1; a--) #define repa(a,b) for(auto a:b) #define ll long long #define pll pair<ll, ll> #define fi first #define se second #define pb push_back using namespace std; using vi = vector<int>; const int N=2005; int dsu[N], sz[N]; int find(int x){ if(dsu[x]==-1) return x; return dsu[x]=find(dsu[x]); } void join(int a, int b){ a=find(a); b=find(b); if(a==b) return; dsu[a]=b; sz[b]+=sz[a]; } void solve(vi a){ if(a.size()<=1) return; move_inside(a[0]); rep(i,1,a.size()){ move_inside(a[i]); if(press_button()==2) join(a[i],a[i-1]); move_outside(a[i-1]); } move_outside(a.back()); vi b, c; b.pb(a[0]); rep(i,1,a.size()){ if(find(a[i])==find(a[i-1])) continue; b.swap(c); b.pb(a[i]); } solve(b); solve(c); } int min_cardinality(int n) { int ans=n; vi a; fill(dsu,dsu+n,-1); fill(sz,sz+n,1); rep(i,0,n) a.pb(i); solve(a); rep(i,0,n) ans=min(ans,sz[find(i)]); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...