제출 #631036

#제출 시각아이디문제언어결과실행 시간메모리
631036gromperen드문 곤충 (IOI22_insects)C++17
47.51 / 100
261 ms532 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(int N) { vector<int> insects; int cnt_uniq = 0; for (int i = 0; i < N; ++i) { move_inside(i); if (press_button() == 1) cnt_uniq++; else { move_outside(i); insects.push_back(i); } } int ans = 1; int low = 2, high = N/cnt_uniq; while(low<=high) { int mid = (low+high)/2; vector<int> in, out; for (int i : insects) { move_inside(i); if (press_button() > mid) { move_outside(i); out.push_back(i); } else { in.push_back(i); } } if (in.size() == cnt_uniq * (mid-1)) { low = mid+1; ans = mid; } else { high = mid-1; for (auto i : in) move_outside(i); insects = in; } } return ans; }

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

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:33:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |   if (in.size() == cnt_uniq * (mid-1)) {
      |       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...