Submission #827044

#TimeUsernameProblemLanguageResultExecution timeMemory
827044lollipopRarest Insects (IOI22_insects)C++17
10 / 100
318 ms336 KiB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define ll long long
//#define int long long
#define pb push_back
#define s second
#define f first
#define pf push_front
#define inf 1000000000000000
#define bitebi __builtin_popcountll
#define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
#define YES cout <<"YES\n"
#define NO cout << "NO\n"
#define debug cout << "Here Fine" << endl ;
#define pr pair < int , int >
#define fbo find_by_order // returns iterator
#define ook order_of_key // returns strictly less numbers than key
using namespace std ;
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const double Pi=acos(-1.0);
const double EPS=1E-8;
const int mod =  1000000007 ;
const int mod1 = 998244353 ;
const int N = 4e5 + 10 ;
//mt19937 R(time(0));
map < string , int > ma , ma1 ;
     
#include "insects.h"

// void move_inside(int i){
//   return 0 ;
// }
// void move_outside(int i){
// return 0 ;
// }
// int press_button(){
// return 0 ;
// }


int min_cardinality(int N){
   int tp[ N ] ;
   FOR( i , N ) tp[ i ] = 0 ;
   int cc = 1 , mn = INT_MAX ;
   int count = 0 ;
   vector < int > v ;
   FOR( i , N ) v.pb( i ) ;
   random_shuffle( v.begin() , v.end() ) ;
    random_shuffle( v.begin() , v.end() ) ;
   for( int I = 0 ; I < N ; I ++ ){
    int i = v[ I ] ; 
     if( tp[ i ] != 0 ) continue ;
     if( tp[ i ] == 0 ){
      tp[ i ] = cc ; cc ++ ;
     }     
     int cnt = 1 ;
     if( cnt >= mn ) continue ;
     move_inside( i ) ;
     count ++ ;
      if( count == 40000 ) return mn ;
     for( int J = I + 1 ; J < N ; J ++ ){
      int j = v[ J ] ;
       if( tp[ j ] != 0  ) continue ;
       move_inside( j ) ;
       count ++ ;
       if( count == 40000 ) return mn ;
       int cc = press_button() ;
       if( cc == 2 ){
        cnt ++ ;
        tp[ j ] = tp[ i ] ;
       }
       move_outside( j ) ;
    //   if( cnt >= mn ) break ;
     }
     mn = min( mn , cnt ) ;
     move_outside( i ) ; 
   }
   return mn ;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...