답안 #852322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
852322 2023-09-21T15:16:57 Z fadi57 드문 곤충 (IOI22_insects) C++17
0 / 100
0 ms 344 KB
    #include<bits/stdc++.h>
    #include "insects.h"

    using namespace std;
    int n;
    const int mx=2e7+10;
    map<int,int>in;
   int sz=0; int d=0;
    bool check(int x){

    for(int i=0;i<n;i++){
        
            move_inside(i);
            int z=press_button();
            if(z>x){
                move_outside(i);
            }else{
              in[i]=1;
                sz++;
                
                }
        
    }
     int z=press_button();
      for(int i=0;i<n;i++){
        if(in[i]){
          
           move_outside(i);
            in[i]=0;
        }
    }
     if(sz==d*x){return 1;}else{return 0;}
    
    }
 int min_cardinality(int N){
     int arr[N+1];
     n=N;
     for(int i=0;i<N;i++){
        arr[i]=-1;
     }
   
    
    for(int i=0;i<N;i++){
        move_inside(i);
        //in[i]=1;
        d++;
        int z=  press_button();
         if(z>1){
               move_outside(i);
                 in[i]=0;d--;
         }else{sz++;}
       

    }
    int l=1;int r=N;
    int ans=0;
    while(l<=r){
        int mid=(l+r)/2;
        sz=0;
        if(check(mid)){
            l=mid+1;
            ans=l;
        }else{
         r=mid-1;
        }
        
        
        
    }
 return ans;


 }
 /*
int main(){
cout<<min_cardinality(9);


}*/

Compilation message

insects.cpp: In function 'bool check(int)':
insects.cpp:24:10: warning: unused variable 'z' [-Wunused-variable]
   24 |      int z=press_button();
      |          ^
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:36:10: warning: variable 'arr' set but not used [-Wunused-but-set-variable]
   36 |      int arr[N+1];
      |          ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -