Submission #1076544

# Submission time Handle Problem Language Result Execution time Memory
1076544 2024-08-26T14:38:46 Z Boas Rarest Insects (IOI22_insects) C++17
0 / 100
4 ms 344 KB
#include "insects.h"

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define loop(x, i) for (int i = 0; i < x; i++)
#define rev(x, i) for (int i = (int)x - 1; i >= 0; i--)
#define ALL(x) begin(x), end(x)
#define sz(x) (int)x.size()

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;

int min_cardinality(int N)
{
  vi ix(N);
  iota(ALL(ix), 0);
  // std::random_device rd;
  // std::mt19937 g(rd());
  // std::shuffle(ix.begin(), ix.end(), g);
  vvi S(N);
  int iter = 1;
  S[0].pb(0);
  move_inside(ix[0]);
  for (int i = 1; i < N; i++)
  {
    move_inside(ix[i]);
    int res = press_button();
    if (res == 2)
    {
      move_outside(ix[i]);
      S[1].pb(i);
    }
    else
      S[0].pb(i);
  }
  int t = sz(S[0]);
  if (t == 1)
    return N;
  while (sz(S[iter]))
  {
    if (sz(S[iter]) < t)
      return iter;
    int curSize = 1;
    for (int i : S[iter - 1])
      move_outside(ix[i]);
    move_inside(ix[S[iter][0]]);
    vi newCurS = {S[iter][0]};
    for (int s_ix = 1; s_ix < sz(S[iter]); s_ix++)
    {
      int i = S[iter][s_ix];
      move_inside(ix[i]);
      int res = press_button();
      if (res == 2)
      {
        move_outside(ix[i]);
        S[iter + 1].pb(i);
      }
      else
      {
        curSize++;
        newCurS.pb(i);
      }
      if (curSize == t)
      {
        for (int s_ix2 = s_ix + 1; s_ix2 < sz(S[iter]); s_ix2++)
        {
          S[iter + 1].pb(s_ix2);
        }
        break;
      }
    }
    if (curSize < t)
      return iter;
    S[iter] = newCurS;
    iter++;
  }
  return iter;
}
# 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 1 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 2 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Incorrect 4 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 1 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 2 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Incorrect 4 ms 344 KB Wrong answer.
9 Halted 0 ms 0 KB -
# 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 1 ms 344 KB Output is correct
6 Incorrect 1 ms 344 KB Wrong answer.
7 Halted 0 ms 0 KB -