Submission #658469

#TimeUsernameProblemLanguageResultExecution timeMemory
658469coding_snorlaxRarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include "insects.h" #include<bits/stdc++.h> using namespace std; int All_type[2000]={0}; int Box[2000]={0}; int Check[2000]={0}; int All_possible[2000]; int Total_N; int level_1; int check(int Num){ //cout<<Total_N<<"Total_N"<<endl; int tmp; for(int j=0;j<Total_N;j++){ //cout<<"All_possible "<<All_possible[j]<<" Check "<<Check[j]<<endl; if(All_possible[j] && !Check[j]){ //cout<<j<<endl; move_inside(j); tmp=press_button(); if(tmp>Num){ move_outside(j); } else{ //now_active Check[j]=2; } } } int Count=0; for(int j=0;j<Total_N;j++){ if(Check[j]) { Count++; } } if(Count<level_1*Num){ for(int j=0;j<Total_N;j++){ if(Check[j]==2){ move_outside(j); Check[j]=0; } else if(!Check[j]) All_possible[j]=0; } return 0; } for(int j=0;j<Total_N;j++){ if(Check[j]==2){ Check[j]=1; } } return 1; } int min_cardinality(int N){ Total_N=N; for(int j=0;j<N;j++){ All_possible[j]=1; } for(int j=0;j<N;j++){ int tmp; if(!All_type[j]){ move_inside(j); tmp=press_button(); if(tmp>1){ move_outside(j); } else{ Check[j]=1; } } } int Count=0; for(int j=0;j<N;j++){ if(Check[j]==1) { move_outside(j); Check[j]=0; Count++; } } level_1=Count; //binary_search int L=1,R=M/level_1+1; while(L!=R){ if((R-L)<=2){ if(check(L+1)){ if(check(L+2)) return L+2; return L+1; } return L; } int M=(L+R)/2; if(check(M)) L=M; else R=M+1; } return L; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:80:15: error: 'M' was not declared in this scope
   80 |     int L=1,R=M/level_1+1;
      |               ^