Submission #827065

# Submission time Handle Problem Language Result Execution time Memory
827065 2023-08-16T08:29:54 Z Amylopectin Rarest Insects (IOI22_insects) C++17
0 / 100
1 ms 208 KB
#include "insects.h"
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
const int mxn = 5e3 + 10;
int io[mxn] = {};
int min_cardinality(int n) 
{
  int i,j,cn,cm,fn,fm,cou = 0,cl,cr,mid,ndif;
  move_inside(0);
  cou ++;
  for(i=1; i<n; i++)
  {
    move_inside(i);
    cou ++;
    io[i] = 1;
    cn = press_button();
    if(cn == 2)
    {
      move_outside(i);
      io[i] = 0;
      cou --;
    }
  }
  cl = 1;
  cr = n / cou;
  ndif = cou;
  while(cl < cr)
  {
    mid = (cl+cr) / 2 + (cl+cr) % 2;
    for(i=0; i<n; i++)
    {
      if(io[i] == 0)
      {
        move_inside(i);
        cou ++;
        io[i] = 1;
        cn = press_button();
        if(cn > mid)
        {
          move_outside(i);
          io[i] = 0;
          cou --;
        }
      }
    }
    if(mid * ndif == cou)
    {
      cl = mid;
    }
    else 
    {
      for(i=0; i<n; i++)
      {
        if(io[i] == 1)
        {
          move_outside(i);
          io[i] = 0;
          cou --;
        }
      }
      cr = mid-1;
    }
  }
  return cl;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:10:9: warning: unused variable 'j' [-Wunused-variable]
   10 |   int i,j,cn,cm,fn,fm,cou = 0,cl,cr,mid,ndif;
      |         ^
insects.cpp:10:14: warning: unused variable 'cm' [-Wunused-variable]
   10 |   int i,j,cn,cm,fn,fm,cou = 0,cl,cr,mid,ndif;
      |              ^~
insects.cpp:10:17: warning: unused variable 'fn' [-Wunused-variable]
   10 |   int i,j,cn,cm,fn,fm,cou = 0,cl,cr,mid,ndif;
      |                 ^~
insects.cpp:10:20: warning: unused variable 'fm' [-Wunused-variable]
   10 |   int i,j,cn,cm,fn,fm,cou = 0,cl,cr,mid,ndif;
      |                    ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Wrong answer.
2 Halted 0 ms 0 KB -