Submission #627465

# Submission time Handle Problem Language Result Execution time Memory
627465 2022-08-12T15:20:45 Z inwbear Rarest Insects (IOI22_insects) C++17
0 / 100
1 ms 228 KB
#include "insects.h"
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using namespace std;

int cc[2005],re,sq;
pair<int,int>pos[2005];
bool ins[2005];

int min_cardinality(int N) {
  re=N;
  vector<int>v;
  vector<pair<int,int> >fr;
  for(int i=0;i<N;i++){
    move_inside(i);
    if(press_button()>1){
      move_outside(i);
      fr.pb({i,false});
    }
    else v.pb(i),ins[i]=true;
  }
  sq=(int)sqrt(v.size());
  for(int i=0;i<v.size();i++)move_inside(v[i]);
  for(int i=0;i<v.size();i+=sq){
    for(int j=i;j<v.size()&&j<i+sq;j++){
      move_inside(v[j]);
    }
    for(int j=0;j<fr.size();j++){
      if(fr[j].S)continue;
      move_inside(fr[j].F);
      if(press_button()>1){
        fr[j].S=true;
        pos[fr[j].F].F=i/sq;
      }
      move_outside(fr[j].F);
    }
    for(int j=i;j<v.size()&&j<i+sq;j++){
      move_outside(v[j]);
    }
  }
  for(int i=0;i<sq;i++){
    for(int j=i;j<v.size();j+=sq){
      move_inside(v[j]);
    }
    for(int j=0;j<fr.size();j++){
      if(!fr[j].S)continue;
      move_inside(fr[j].F);
      if(press_button()>1){
        fr[j].S=false;
        pos[fr[j].F].S=i;
      }
      move_outside(fr[j].F);
    }
    for(int j=i;j<v.size();j+=sq){
      move_inside(v[j]);
    }
  }
  for(int i=0;i<fr.size();i++){
    cc[(pos[fr[i].F].F*sq)+pos[fr[i].F].S]++;
  }
  for(int i=0;i<v.size();i++)re=min(re,cc[v[i]]+1);
  return re;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for(int i=0;i<v.size();i++)move_inside(v[i]);
      |               ~^~~~~~~~~
insects.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int i=0;i<v.size();i+=sq){
      |               ~^~~~~~~~~
insects.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int j=i;j<v.size()&&j<i+sq;j++){
      |                 ~^~~~~~~~~
insects.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int j=0;j<fr.size();j++){
      |                 ~^~~~~~~~~~
insects.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int j=i;j<v.size()&&j<i+sq;j++){
      |                 ~^~~~~~~~~
insects.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int j=i;j<v.size();j+=sq){
      |                 ~^~~~~~~~~
insects.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int j=0;j<fr.size();j++){
      |                 ~^~~~~~~~~~
insects.cpp:56:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for(int j=i;j<v.size();j+=sq){
      |                 ~^~~~~~~~~
insects.cpp:60:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |   for(int i=0;i<fr.size();i++){
      |               ~^~~~~~~~~~
insects.cpp:63:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   for(int i=0;i<v.size();i++)re=min(re,cc[v[i]]+1);
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 228 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Incorrect 1 ms 208 KB Wrong answer.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 228 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Incorrect 1 ms 208 KB Wrong answer.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Partially correct 1 ms 208 KB Output is partially correct
3 Partially correct 0 ms 208 KB Output is partially correct
4 Partially correct 0 ms 208 KB Output is partially correct
5 Partially correct 1 ms 208 KB Output is partially correct
6 Incorrect 1 ms 208 KB Wrong answer.
7 Halted 0 ms 0 KB -