제출 #627797

#제출 시각아이디문제언어결과실행 시간메모리
627797ETK드문 곤충 (IOI22_insects)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> //#include "insects.h" #define rep(i,a,b) for(int i=(a);i<=(b);++i) #define per(i,a,b) for(int i=(a);i>=(b);--i) #define pii pair<int,int> #define vi vector<int> #define fi first #define se second #define pb push_back #define ALL(x) x.begin(),x.end() #define sz(x) int(x.size()) #define ll long long using namespace std; const int N = 2e5 + 5; //int n,a[N],b[N]; // void move_inside(int i){ // ++b[a[i]]; // } // void move_outside(int i){ // --b[a[i]]; // } // int press_button(){ // int mx = 0; // rep(i,1,n)mx = max(mx,b[i]); // return mx; // } int min_cardinality(int n){ srand(time(0)); int cnt = 0; vi vis(n,0); rep(i,0,n - 1){ move_inside(i); //appeared before if(i && press_button() > 1)move_outside(i); else vis[i] = 1,cnt++; } int tmp = cnt,L = 2,R = n / cnt,ans = 1; vi rem,p(n); iota(ALL(p),0); while(L <= R){ int k = (L + R) >> 1; random_shuffle(ALL(p)); rep(t,0,n - 1){ int i = p[t]; if(vis[i])continue; move_inside(i); if(press_button() > k){ move_outside(i); rem.pb(i); } else tmp++; if(tmp == k * cnt){//all kind are in the bucket rep(j,i + 1,n - 1)if(!vis[p[j]]){ rem.pb(p[j]); } } } if(k * cnt == tmp){ ans = k,L = k + 1; //if greater than k, you don't need to throw away the insects in your bucket. //You only need to consider the insects left. rep(i,0,n - 1)vis[i] = 1; for(int x : rem)vis[x] = 0; }else{ R = k - 1; //if the answer is smaller than k,you won't need the (k+1)th insects for(int x : rem)vis[x] = 1; rep(i,0,n - 1)if(!vis[i]){ move_outside(i); tmp--; } } rem.clear(); } return ans; } // int main(){ // cin >> n; // rep(i,0,n - 1)cin >> a[i]; // cout << min_cardinality(n) << '\n'; // }

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:32:9: error: 'move_inside' was not declared in this scope
   32 |         move_inside(i);
      |         ^~~~~~~~~~~
insects.cpp:34:17: error: 'press_button' was not declared in this scope
   34 |         if(i && press_button() > 1)move_outside(i);
      |                 ^~~~~~~~~~~~
insects.cpp:34:36: error: 'move_outside' was not declared in this scope
   34 |         if(i && press_button() > 1)move_outside(i);
      |                                    ^~~~~~~~~~~~
insects.cpp:46:13: error: 'move_inside' was not declared in this scope
   46 |             move_inside(i);
      |             ^~~~~~~~~~~
insects.cpp:47:16: error: 'press_button' was not declared in this scope
   47 |             if(press_button() > k){
      |                ^~~~~~~~~~~~
insects.cpp:48:17: error: 'move_outside' was not declared in this scope
   48 |                 move_outside(i);
      |                 ^~~~~~~~~~~~
insects.cpp:69:17: error: 'move_outside' was not declared in this scope
   69 |                 move_outside(i);
      |                 ^~~~~~~~~~~~