답안 #998479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
998479 2024-06-14T03:52:44 Z kym 드문 곤충 (IOI22_insects) C++17
0 / 100
1 ms 600 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
set<int> head;
int min_cardinality(int N) {
  set<int>active;
  for(int i=0;i<N;i++){
    active.insert(i);
    move_inside(i);
    int res=press_button();
    if(res == 1){
      head.insert(i);
      //move_outside(i);
    } else{
      move_outside(i);
    }
  }
  for(auto x:head)move_outside(x);
  int sum = N;
  while(head.size() > 1){
    //cerr<<head.size()<<endl;
    int L = (int)sum / (int)head.size() ;
    // we will be keeping the groups that are < L only
    set<int> toerase;
    set<int>rmvhead;
    for(auto x:active){
      if(head.find(x) == head.end()){
        move_inside(x);
        int res=press_button();
        if(res == L){
          toerase.insert(x);
          move_outside(x);
          sum --;
        }
      } else{
        continue;
      }
    }
    bool have=0;
    for(auto x:head){
      move_inside(x);
      int res=press_button();
      if(res == L){
        toerase.insert(x);
        rmvhead.insert(x);
        move_outside(x);
        sum-=L;
      } else{
        have = 1;
        move_outside(x);
      }
      //cerr << L<<":"<<have<<endl;
    }
    if(!have) return L;
    for(auto x:rmvhead)head.erase(x);
    for(auto x:toerase)active.erase(x);
  }
  assert(0);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -