Submission #628230

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

Compilation message (stderr)

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