Submission #802138

#TimeUsernameProblemLanguageResultExecution timeMemory
802138lollipopCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
1 ms208 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 pb push_back
#define s second
#define f first
#define pf push_front
#define inf 100000000000000000
#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 NN = 2e5 + 10 ;
mt19937 R(time(0));
map < int , int > ma , ma1 ;

#include "mushrooms.h"

// int use_machine(std::vector<int> x){

// }


int count_mushrooms(int n){
    vector < int > a , b ; 
    a.pb( 0 ) ;
    for( int i = 1 ; i < min( n , 22 ) ; i ++ ){
      vector < int > v ;
      v.pb( 0 ) ; v.pb( i );
      int x = use_machine( v ) ;
      if( x == 0 ) a.pb( i ) ;
      else b.pb( i ) ;
    }
    if( a.size() + b.size() == n ) return a.size() ;
    int tt = 0 ;
    if( a.size() < 10 ){
      tt = 1 ;
      swap( a , b ) ;
    }
    for( int j = 22 ; j < n ; j ++ ){
      int lf = n - j + 1 ; 
      int jj = j ; 
      vector < int > v ;
      if( lf >= 10 ){
        FOR( i , 10 ){
          v.pb( a[ i ] ) ;
           v.pb( jj ) ; jj ++ ;
        }
      } 
      else{
        FOR( i , lf ){
          v.pb( a[ i ] ) ;
          v.pb( jj ) ; jj ++ ;
        } 
      }
      int x = use_machine( v ) ;
      while( x > 0 ){
         a.pb( -1 ) ;
         x -= 2 ;
      }
      j = jj - 1 ;
    }



    if( tt == 0 ) return a.size() ;
    else return n - a.size() ;

}

//int use_machine(std::vector<int> x)

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:50:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |     if( a.size() + b.size() == n ) return a.size() ;
      |         ~~~~~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...