Submission #628266

#TimeUsernameProblemLanguageResultExecution timeMemory
628266galcaRarest Insects (IOI22_insects)C++17
0 / 100
1 ms208 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 = 1; 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 iter = 1; while ((vec1.size() + vec2.size()) > 0) { ++iter; 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; } distinct.erase(distinct.begin(), distinct.end()); src.erase(src.begin(), src.end()); dir ^= 1; } return iter; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for (int i = 0; i < vec1.size(); i++) {
      |                  ~~^~~~~~~~~~~~~
insects.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for (int i = 0; i < distinct.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~~~
insects.cpp:50:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for (int i = 0; i < src.size(); i++) {
      |                   ~~^~~~~~~~~~~~
insects.cpp:61:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |   if (distinct.size() != num_sets) {
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~
insects.cpp:10:6: warning: unused variable 'min_card' [-Wunused-variable]
   10 |  int min_card = N;
      |      ^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...