제출 #1241778

#제출 시각아이디문제언어결과실행 시간메모리
1241778nikulid드문 곤충 (IOI22_insects)C++20
0 / 100
0 ms408 KiB
#include "insects.h" #include <vector> #include <iostream> using namespace std; bool debug=1; #define derr if(debug)cerr int min_cardinality(int N) { // go around to find the value of D vector<int> type(N, 0); vector<int> ogtype(N,0); vector<bool> is_in(N,false); vector<bool> is_in_l(N, false); int D=1; move_inside(0); ogtype[0]=1; type[0]=1; is_in[0]=true; for(int i=1; i<N; i++){ move_inside(i); if(press_button() > 1){ // this is a repeat :p move_outside(i); } else{ // this is a new :/ D++; ogtype[i]=D; type[i]=D; is_in[i]=1; is_in_l[i]=1; } } derr<<"$ we have found that D="<<D<<"\n"; // now we know D ig if(D > N/2) return 1; int curD = 1; int l=1, r=N, m=(l+r+1)/2; bool incr=1, is_less; int I; while(r != l){ derr<<"$ (l,r): ("<<l<<","<<r<<")\n"; // check m I=0; for(int i=0; i<N; i++){ if(is_in[i] && !is_in_l[i]){ move_outside(i); is_in[i]=0; } if(is_in[i]){ I++; } } for(int i=1; i<N; i++){ // we currently only have the OGs in if(!is_in[i]){ move_inside(i); if(press_button() > m){ move_outside(i); } else{ I++; is_in[i]=1; } } } if(I == D*m){ is_less = 0; } else{ is_less = 1; } if(is_less){ r = m-1; incr = 0; } else{ for(int i=0; i<N; i++){ if(is_in[i]){ is_in_l[i]=1; } } l = m; incr = 1; } m = (l+r+1)/2; } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...