Submission #788941

#TimeUsernameProblemLanguageResultExecution timeMemory
788941mosiashvililukaRarest Insects (IOI22_insects)C++17
0 / 100
9 ms208 KiB
#include<bits/stdc++.h> #include "insects.h" using namespace std; int a,b,c,d,e,i,j,ii,jj,zx,xc,lef,rig,mid,bo[2009],raod,BO[2009],ZED[2009],FORA; vector <int> diff; void ADD(int i){ move_inside(i-1);bo[i]=1; } void REM(int i){ move_outside(i-1);bo[i]=0; } int ask(){ return press_button(); } int min_cardinality(int NN) { a=NN; for(i=1; i<=a; i++){ ADD(i); c=ask(); if(c>1){ REM(i); }else{ diff.push_back(i); } } for(i=1; i<=a; i++){ if(bo[i]==1) REM(i); } raod=diff.size(); lef=1;rig=a/raod+1; while(1){ if(lef+1>=rig) break; mid=(lef+rig)/2; for(i=0; i<=a+1; i++){ ZED[i]=0; } for(i=1; i<=a; i++){ if(BO[i]==1) continue; ADD(i); c=ask(); if(c>mid){ REM(i);ZED[i]=1; }else{ ; } } zx=0; for(i=1; i<=a; i++){ if(bo[i]==1) zx++; } if(zx==(mid-FORA)*raod){ lef=mid;FORA=mid; for(i=1; i<=a; i++){ if(bo[i]==1){ BO[i]=1;//shegidzlia yvelas mid occurence amoshalo } } }else{ rig=mid; for(i=1; i<=a; i++){ if(ZED[i]==1){ BO[i]=1; } } } for(i=1; i<=a; i++){ if(bo[i]==1) REM(i); } } return lef; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...