Submission #988496

# Submission time Handle Problem Language Result Execution time Memory
988496 2024-05-25T04:16:29 Z cnn008 Rarest Insects (IOI22_insects) C++17
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;

#include "insects.h";

#ifdef N_N_C
#include "debug.h"
#else
#define cebug(...) "Arya"
#endif

#define ll long long

const int N=1e5+5;
const int mod=1e9+7;

int cad,vis[1005],type;
void in(int i){
	s.insert(i);
	move_inside(i);
}
void out(int i){
	s.erase(s.find(i));
	move_outside(i);
}
int min_cardinality(int n){
	for(int i=0; i<n; i++){
		in(i);
		if(press_button()>cad) cad++;
		else out(i);
	}
	for(auto i:s) out(i);
	if(cad<=30){
		for(int i=0; i<n; i++){
			if(!vis[i]){
				vis[i]=++type;
				move_inside(i);
				for(int j=i+1; j<n; j++){
					move_inside(j);
					int val=press_button();
					if(val==2) vis[j]=type;
					move_outside(j);
				}
				move_outside(i);
			}
		}
		map <int,int> mp;
		for(int i=0; i<n; i++) mp[vis[i]]++;
		int ans=INT_MAX;
		for(auto [x,y]:mp) ans=min(ans,y);
		return ans;
	}else{
		int cnt=0;
		for(int i=0; i<n; i++){
			if(!vis[i]){
				cnt++;
				vis[i]=1;
				move_inside(i);
				int sz=1;
				for(int j=i+1; j<n; j++){
					move_inside(j);
					if(press_button()>sz){
						sz++;
						vis[j]=1;
					}else move_outside(j);
				}
				if(press_button()<cad) return cnt;
				move_outside(i);
				for(int j=i+1; j<n; j++) if(vis[j]) move_outside(j);
			}
		}
	}
}
/**  /\_/\
*   (= ._.)
*   / >💖 \>💕
**/

Compilation message

insects.cpp:4:21: warning: extra tokens at end of #include directive
    4 | #include "insects.h";
      |                     ^
insects.cpp:74:9: warning: "/*" within comment [-Wcomment]
   74 | /**  /\_/\
      |          
insects.cpp: In function 'void in(int)':
insects.cpp:19:2: error: 's' was not declared in this scope
   19 |  s.insert(i);
      |  ^
insects.cpp: In function 'void out(int)':
insects.cpp:23:2: error: 's' was not declared in this scope
   23 |  s.erase(s.find(i));
      |  ^
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:32:13: error: 's' was not declared in this scope
   32 |  for(auto i:s) out(i);
      |             ^