Submission #998578

# Submission time Handle Problem Language Result Execution time Memory
998578 2024-06-14T09:18:07 Z kym Rarest Insects (IOI22_insects) C++17
91.25 / 100
55 ms 1236 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
set<int> head;
set<int>in;
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;
  vector<int> extra;
  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()){
        in.insert(x);
        move_inside(x);
        int res=press_button();
        if(res == L){
          toerase.insert(x);
          move_outside(x);
          in.erase(x);
          --sum;
        }
      } else{
        continue;
      }
    }
    for(auto &x:extra){
      int neg = x-(L-1);
      if(neg > 0){
        sum += neg;
        x=L-1;
      }  
    }
    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;
        extra.push_back(L-1);
      } else{
        have = 1;
        move_outside(x);
      }
      //cerr << L<<":"<<have<<endl;
    }
    //cerr << L<<":"<<have<<endl;
    if(!have) return L;
    for(auto x:rmvhead)head.erase(x);
    for(auto x:toerase)active.erase(x);
    for(auto x:in)move_outside(x);
    in.clear();
  }
  return sum;
  assert(0);
}
# 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 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 5 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 444 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 3 ms 440 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 3 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 3 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
# 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 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 5 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 444 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 3 ms 440 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 3 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 3 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 7 ms 344 KB Output is correct
24 Correct 9 ms 788 KB Output is correct
25 Correct 10 ms 604 KB Output is correct
26 Correct 19 ms 600 KB Output is correct
27 Correct 8 ms 600 KB Output is correct
28 Correct 7 ms 764 KB Output is correct
29 Correct 9 ms 484 KB Output is correct
30 Correct 7 ms 344 KB Output is correct
31 Correct 10 ms 344 KB Output is correct
32 Correct 11 ms 476 KB Output is correct
33 Correct 19 ms 344 KB Output is correct
34 Correct 19 ms 600 KB Output is correct
35 Correct 22 ms 344 KB Output is correct
36 Correct 19 ms 344 KB Output is correct
37 Correct 16 ms 344 KB Output is correct
38 Correct 12 ms 600 KB Output is correct
39 Correct 13 ms 344 KB Output is correct
40 Correct 16 ms 600 KB Output is correct
41 Correct 8 ms 600 KB Output is correct
# 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 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 10 ms 344 KB Output is correct
8 Correct 18 ms 1004 KB Output is correct
9 Correct 14 ms 584 KB Output is correct
10 Partially correct 41 ms 592 KB Output is partially correct
11 Correct 28 ms 600 KB Output is correct
12 Correct 22 ms 804 KB Output is correct
13 Correct 20 ms 592 KB Output is correct
14 Correct 19 ms 600 KB Output is correct
15 Correct 28 ms 836 KB Output is correct
16 Partially correct 55 ms 848 KB Output is partially correct
17 Correct 44 ms 600 KB Output is correct
18 Partially correct 37 ms 560 KB Output is partially correct
19 Partially correct 31 ms 636 KB Output is partially correct
20 Partially correct 52 ms 600 KB Output is partially correct
21 Partially correct 51 ms 832 KB Output is partially correct
22 Partially correct 53 ms 592 KB Output is partially correct
23 Partially correct 46 ms 592 KB Output is partially correct
24 Correct 29 ms 520 KB Output is correct
25 Correct 26 ms 572 KB Output is correct
26 Correct 27 ms 600 KB Output is correct
27 Correct 24 ms 764 KB Output is correct
28 Correct 13 ms 848 KB Output is correct
29 Correct 17 ms 592 KB Output is correct
30 Correct 16 ms 592 KB Output is correct
31 Correct 23 ms 760 KB Output is correct
32 Correct 21 ms 600 KB Output is correct
33 Correct 22 ms 608 KB Output is correct
34 Correct 12 ms 592 KB Output is correct
35 Correct 20 ms 600 KB Output is correct
36 Correct 17 ms 592 KB Output is correct
37 Correct 16 ms 592 KB Output is correct
38 Correct 17 ms 600 KB Output is correct
39 Correct 22 ms 588 KB Output is correct
40 Correct 16 ms 724 KB Output is correct
41 Correct 18 ms 1236 KB Output is correct
42 Correct 21 ms 544 KB Output is correct
43 Correct 5 ms 452 KB Output is correct
44 Correct 25 ms 600 KB Output is correct
45 Correct 22 ms 624 KB Output is correct
46 Correct 28 ms 600 KB Output is correct
47 Correct 25 ms 848 KB Output is correct
48 Correct 31 ms 600 KB Output is correct