제출 #629159

#제출 시각아이디문제언어결과실행 시간메모리
629159flashmt드문 곤충 (IOI22_insects)C++17
99.89 / 100
69 ms560 KiB
#include <bits/stdc++.h> #include "insects.h" using namespace std; pair<vector<int>, vector<int>> findFirstOccurrences(vector<int> id, int maxC) { vector<int> good, bad; for (int i : id) { move_inside(i); if (press_button() <= maxC) good.push_back(i); else { move_outside(i); bad.push_back(i); } } for (int i : good) move_outside(i); return {good, bad}; } int min_cardinality(int n) { vector<int> id(n); iota(begin(id), end(id), 0); auto [good, bad] = findFirstOccurrences(id, 1); int typeCnt = size(good); int low = 2, high = n / typeCnt, ans = 1; id = bad; while (low <= high) { int mid = (low + high) / 2; tie(good, bad) = findFirstOccurrences(id, mid - ans); if (size(good) == typeCnt * (mid - ans)) { ans = mid; low = mid + 1; id = bad; } else { high = mid - 1; id = good; } } return ans; }

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

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