제출 #629605

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

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

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