Submission #628269

#TimeUsernameProblemLanguageResultExecution timeMemory
628269galcaRarest Insects (IOI22_insects)C++17
10 / 100
441 ms300 KiB
#include "insects.h" #include <vector> using namespace std; int min_cardinality(int N) { vector<int> vec1; vector<int> vec2; for (int i = 0; i < N; i++) { vec1.push_back(i); } vector<int> distinct; for (int i = 0; i < vec1.size(); i++) { move_inside(vec1[i]); int res = press_button(); if (res != 1) { move_outside(vec1[i]); vec2.push_back(vec1[i]); } else { distinct.push_back(vec1[i]); } } int num_sets = distinct.size(); if (num_sets == N) { return 1; } for (int i = 0; i < distinct.size(); i++) { move_outside(distinct[i]); } distinct.erase(distinct.begin(), distinct.end()); vec1.erase(vec1.begin(), vec1.end()); int dir = 1; int iter = 1; while ((vec1.size() + vec2.size()) > 0) { vector<int>& src = dir ? vec2 : vec1; vector<int>& dst = dir ? vec1 : vec2; vector<int> distinct; for (int i = 0; i < src.size(); i++) { move_inside(src[i]); int res = press_button(); if (res != 1) { move_outside(src[i]); dst.push_back(src[i]); } else { distinct.push_back(src[i]); } } if (distinct.size() != num_sets) { return iter; } for (int i = 0; i < distinct.size(); i++) { move_outside(distinct[i]); } distinct.erase(distinct.begin(), distinct.end()); src.erase(src.begin(), src.end()); dir ^= 1; ++iter; } return iter; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:15:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for (int i = 0; i < vec1.size(); i++) {
      |                  ~~^~~~~~~~~~~~~
insects.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for (int i = 0; i < distinct.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~~~
insects.cpp:47:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for (int i = 0; i < src.size(); i++) {
      |                   ~~^~~~~~~~~~~~
insects.cpp:58:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |   if (distinct.size() != num_sets) {
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~
insects.cpp:62:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |   for (int i = 0; i < distinct.size(); i++) {
      |                   ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...