Submission #1064204

# Submission time Handle Problem Language Result Execution time Memory
1064204 2024-08-18T10:21:29 Z MarwenElarbi Rarest Insects (IOI22_insects) C++17
59.66 / 100
108 ms 1268 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
#define pb push_back
#define ll long long
#define fi first
#define se second
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int nax=2005;
int sz[nax];
vector<int> insects;
vector<int> to_do[nax];
int ls=0;
int rs=-1;
int c=0;
void daq(int l,int r){
  if(l==r){
    sz[l]+=to_do[l].size();
    return;
  }
  int mid=(r+l)/2;
  while(ls<l){
    c--;
    move_outside(insects[ls++]);
  }
  while(ls>l){
    c++;
    move_inside(insects[--ls]);
  }
  while(rs<mid){
    c++;
    move_inside(insects[++rs]);
  }
  while(rs>mid){
    c--;
    move_outside(insects[rs--]);
  }
  vector<int> left,right;
  for(auto u:to_do[mid]){
    move_inside(u);
    int a=press_button();
    if(a==2) left.pb(u);
    else right.pb(u);
    move_outside(u);
  }
  to_do[(mid+l)/2]=left;
  to_do[(mid+1+r)/2]=right;
  daq(l,mid);
  daq(mid+1,r);
  return;
}
int min_cardinality(int N){
  int n=N;
  move_inside(0);
  insects.pb(0);
  int cnt=1;
  vector<int> cur;
  for (int i = 1; i < n; ++i)
  {
    move_inside(i);
    cnt++;
    int a=press_button();
    if(a==2){
      if(cnt<=2) sz[0]++;
      else{
        cur.pb(i);
      }
      move_outside(i);
      cnt--;
    }else{
      insects.pb(i);
    }
  }
  for(auto u:cur) to_do[(insects.size()-1)/2].pb(u);
  for (int i = 0; i < insects.size(); ++i)
  {
    move_outside(insects[i]);
  }
  daq(0,insects.size()-1);
  int mn=1e9; 
  for (int i = 0; i < insects.size(); ++i)
  {
    mn=min(mn,sz[i]);
  }
  return mn+1;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:75:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |   for (int i = 0; i < insects.size(); ++i)
      |                   ~~^~~~~~~~~~~~~~~~
insects.cpp:81:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |   for (int i = 0; i < insects.size(); ++i)
      |                   ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 Correct 4 ms 344 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 3 ms 500 KB Output is correct
13 Correct 3 ms 344 KB Output is correct
14 Correct 5 ms 340 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 6 ms 344 KB Output is correct
18 Correct 4 ms 492 KB Output is correct
19 Correct 7 ms 344 KB Output is correct
20 Correct 4 ms 496 KB Output is correct
21 Correct 7 ms 492 KB Output is correct
22 Correct 3 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 Correct 4 ms 344 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 3 ms 500 KB Output is correct
13 Correct 3 ms 344 KB Output is correct
14 Correct 5 ms 340 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 6 ms 344 KB Output is correct
18 Correct 4 ms 492 KB Output is correct
19 Correct 7 ms 344 KB Output is correct
20 Correct 4 ms 496 KB Output is correct
21 Correct 7 ms 492 KB Output is correct
22 Correct 3 ms 488 KB Output is correct
23 Correct 5 ms 344 KB Output is correct
24 Correct 5 ms 344 KB Output is correct
25 Correct 40 ms 496 KB Output is correct
26 Correct 28 ms 496 KB Output is correct
27 Correct 6 ms 344 KB Output is correct
28 Correct 30 ms 752 KB Output is correct
29 Correct 29 ms 340 KB Output is correct
30 Correct 35 ms 1000 KB Output is correct
31 Correct 16 ms 496 KB Output is correct
32 Correct 23 ms 344 KB Output is correct
33 Correct 28 ms 848 KB Output is correct
34 Correct 23 ms 756 KB Output is correct
35 Correct 21 ms 344 KB Output is correct
36 Correct 32 ms 744 KB Output is correct
37 Correct 25 ms 744 KB Output is correct
38 Correct 49 ms 1000 KB Output is correct
39 Correct 31 ms 752 KB Output is correct
40 Correct 32 ms 592 KB Output is correct
41 Correct 24 ms 728 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 11 ms 344 KB Output is correct
8 Partially correct 13 ms 600 KB Output is partially correct
9 Partially correct 77 ms 1268 KB Output is partially correct
10 Partially correct 77 ms 764 KB Output is partially correct
11 Correct 19 ms 504 KB Output is correct
12 Partially correct 71 ms 984 KB Output is partially correct
13 Partially correct 48 ms 744 KB Output is partially correct
14 Partially correct 69 ms 600 KB Output is partially correct
15 Partially correct 47 ms 600 KB Output is partially correct
16 Partially correct 57 ms 592 KB Output is partially correct
17 Partially correct 62 ms 744 KB Output is partially correct
18 Partially correct 53 ms 600 KB Output is partially correct
19 Partially correct 55 ms 600 KB Output is partially correct
20 Partially correct 60 ms 776 KB Output is partially correct
21 Partially correct 78 ms 648 KB Output is partially correct
22 Partially correct 82 ms 600 KB Output is partially correct
23 Partially correct 108 ms 728 KB Output is partially correct
24 Partially correct 99 ms 1024 KB Output is partially correct
25 Partially correct 67 ms 764 KB Output is partially correct
26 Partially correct 53 ms 600 KB Output is partially correct
27 Partially correct 80 ms 772 KB Output is partially correct
28 Partially correct 76 ms 1260 KB Output is partially correct
29 Partially correct 68 ms 1040 KB Output is partially correct
30 Partially correct 81 ms 996 KB Output is partially correct
31 Partially correct 75 ms 752 KB Output is partially correct
32 Partially correct 90 ms 604 KB Output is partially correct
33 Partially correct 87 ms 1048 KB Output is partially correct
34 Partially correct 102 ms 592 KB Output is partially correct
35 Partially correct 72 ms 728 KB Output is partially correct
36 Partially correct 70 ms 992 KB Output is partially correct
37 Partially correct 92 ms 744 KB Output is partially correct
38 Partially correct 74 ms 764 KB Output is partially correct
39 Partially correct 87 ms 856 KB Output is partially correct
40 Partially correct 69 ms 776 KB Output is partially correct
41 Partially correct 63 ms 592 KB Output is partially correct
42 Partially correct 97 ms 860 KB Output is partially correct
43 Partially correct 9 ms 504 KB Output is partially correct
44 Partially correct 31 ms 764 KB Output is partially correct
45 Correct 11 ms 496 KB Output is correct
46 Correct 11 ms 596 KB Output is correct
47 Partially correct 62 ms 756 KB Output is partially correct
48 Partially correct 35 ms 988 KB Output is partially correct