제출 #628256

#제출 시각아이디문제언어결과실행 시간메모리
628256galca드문 곤충 (IOI22_insects)C++17
0 / 100
361 ms292 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); move_inside(i); } while ((vec1.size() + vec2.size()) > 0) { int max_card = press_button(); if (max_card == 1) return 1; vector<int>& src = dir ? vec2 : vec1; vector<int>& dst = dir ? vec1 : vec2; vector<int> rem; for (int i = 0; i < src.size(); i++) { move_outside(src[i]); int res = press_button(); if (res != max_card) { rem.push_back(src[i]); } else { dst.push_back(src[i]); } move_inside(src[i]); } if (dst.size() == 0) { return max_card; } for (int i = 0; i < rem.size(); i++) { move_outside(rem[i]); } rem.erase(rem.begin(), rem.end()); src.erase(src.begin(), src.end()); dir ^= 1; } return 1; }

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:28:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for (int i = 0; i < src.size(); i++) {
      |                   ~~^~~~~~~~~~~~
insects.cpp:42:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for (int i = 0; i < rem.size(); i++) {
      |                   ~~^~~~~~~~~~~~
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...