Submission #982132

# Submission time Handle Problem Language Result Execution time Memory
982132 2024-05-13T23:34:17 Z vjudge1 Rarest Insects (IOI22_insects) C++17
0 / 100
3 ms 756 KB
//viewed solution
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(random_device{}());
vector<int>ins,notin,notin2;
int types,init=0;
bool check(int mid){
  ins.clear();
  notin2.clear();
  shuffle(notin.begin(),notin.end(),rng);
  for(auto i:notin){
    if(init==mid*types) {
      notin2.push_back(i);
      continue;
    }
    move_inside(i);
    if(press_button()-mid)
      move_outside(i),
      notin2.push_back(i);
    else init++,ins.push_back(i);
  }
  return init==mid*types;
}
int min_cardinality(int N) {
  for(int i=0;i<N;i++){
    move_inside(i);
    int val=press_button();
    if(val-1)
      notin.push_back(i),
      move_outside(i);
    else types++;
  }
  if(types==1)
    return N;
  int l=1,r=N/types;
  init=types;
  while(l<r){
    int mid=l+r+1>>1;
    if(check(mid)){
      notin=notin2;
      l=mid;
    } else {
      r=mid-1;
      for(auto i:ins)
        move_outside(i),init--;
    }
  }
  return l;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:39:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   39 |     int mid=l+r+1>>1;
      |             ~~~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 756 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Incorrect 3 ms 344 KB Wrong answer.
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 756 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Incorrect 3 ms 344 KB Wrong answer.
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Incorrect 0 ms 344 KB Wrong answer.
7 Halted 0 ms 0 KB -