# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
851470 | 2023-09-19T23:40:22 Z | fadi57 | Rarest Insects (IOI22_insects) | C++17 | 0 ms | 0 KB |
#include<bits/stdc++.h> // #include "insects.h" using namespace std; int n; const int mx=2e7+10; long long dp[mx]; int min_cardinality(int N){ int arr[N+1]; for(int i=0;i<N;i++){ arr[i]=-1; } map<int,int>mp; for(int i=0;i<n;i++){ move_inside(i); if(arr[i]==-1){ arr[i]=i; } for(int j=i+1;j<n;j++){ move_inside(j); int z= press_button(); if(z==2){ arr[j]=arr[i]; } move_outside(j); } } for(int i=0;i<n;i++){ mp[arr[i]]++; } int ans=n; for(int i=0;i<n;i++){ ans=min(ans,mp[arr[i]]); } return ans; } int main(){ cout<<min_cardinality(9); }