Submission #631752

#TimeUsernameProblemLanguageResultExecution timeMemory
631752AmirElarbiRarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
//#include "insects.h"
#include <bits/stdc++.h>
#define ve vector
#define vi ve<int>
#define ii pair<int,int>
#define ll long long
#define vvi ve<vi>
#define se second
#define fi first
#define pb push_back

using namespace std;
const int nax = 2e3+5;
const int MOD = 1e9+7;

int pref[nax];
int min_cardinality(int n) {
  int type  = 0;
  for (int i = 0; i < n; ++i)
  {
       move_inside(i);
       int a = press_button();
       if(a == 1)
        type++;
       else 
        move_outside(i);
      pref[i] = type;
  }
  for (int i = 0; i < n; ++i)
  {
    move_outside(i);
  }
  int l = 1,r = n/type+1, ans = 0;
  vi cur, vis(n);
  while(l< r){
    int md = (l+r)/2;
    int nb = 0, nl = l;
    for (int i = 0; i < n; ++i)
    {
        if(vis[i]) {
        	nb++;
        	continue;
        }
        move_inside(i);
        int a = press_button();
        int c  = nb/pref[i];
        if(c*pref[i] == nb){
        	nl = c;
        }
        if(a  > md){
            move_outside(i);
        } else {
            cur.pb(i);
            nb++;
        }
    }
    if(type*md == cur.size()){
        for(auto x : cur) vis[x] = 1;
        l = md+1; ans = md; 
    } else {
        r = md;
        l = nl;
        vi nw;
        for (auto i : cur)
        {
        	if(vis[i]){ 
 						nw.pb(i);
        		continue;
        	}
          move_outside(i);
        }
        cur.clear();
        for(auto x : nw) cur.pb(x);  
    }
  }
  return ans;
}

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:21:8: error: 'move_inside' was not declared in this scope
   21 |        move_inside(i);
      |        ^~~~~~~~~~~
insects.cpp:22:16: error: 'press_button' was not declared in this scope
   22 |        int a = press_button();
      |                ^~~~~~~~~~~~
insects.cpp:26:9: error: 'move_outside' was not declared in this scope
   26 |         move_outside(i);
      |         ^~~~~~~~~~~~
insects.cpp:31:5: error: 'move_outside' was not declared in this scope
   31 |     move_outside(i);
      |     ^~~~~~~~~~~~
insects.cpp:44:9: error: 'move_inside' was not declared in this scope
   44 |         move_inside(i);
      |         ^~~~~~~~~~~
insects.cpp:45:17: error: 'press_button' was not declared in this scope
   45 |         int a = press_button();
      |                 ^~~~~~~~~~~~
insects.cpp:51:13: error: 'move_outside' was not declared in this scope
   51 |             move_outside(i);
      |             ^~~~~~~~~~~~
insects.cpp:57:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     if(type*md == cur.size()){
      |        ~~~~~~~~^~~~~~~~~~~~~
insects.cpp:70:11: error: 'move_outside' was not declared in this scope
   70 |           move_outside(i);
      |           ^~~~~~~~~~~~