제출 #628933

#제출 시각아이디문제언어결과실행 시간메모리
628933flashmt드문 곤충 (IOI22_insects)C++17
57.14 / 100
162 ms504 KiB
#include <bits/stdc++.h> #include "insects.h" using namespace std; vector<int> findFirstOccurrences(int n, int maxC) { vector<int> res; for (int i = 0; i < n; i++) { move_inside(i); if (press_button() > maxC) move_outside(i); else res.push_back(i); } for (int i : res) move_outside(i); return res; } int min_cardinality(int n) { auto occurrences = findFirstOccurrences(n, 1); int typeCnt = size(occurrences); if (typeCnt <= 8) { vector<int> cnt(n); for (int i = 0; i < n; i++) { move_inside(i); for (int j : occurrences) { move_inside(j); if (press_button() == 2) { cnt[j]++; move_outside(j); break; } move_outside(j); } move_outside(i); } int ans = n; for (int x : occurrences) ans = min(ans, cnt[x] + 1); return ans; } int low = 2, high = n / typeCnt, ans = 1; while (low <= high) { int mid = (low + high) / 2; auto occ = findFirstOccurrences(n, mid); if (size(occ) == typeCnt * mid) { ans = mid; low = mid + 1; } else high = mid - 1; } return ans; }

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

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