제출 #726138

#제출 시각아이디문제언어결과실행 시간메모리
726138TheSahib드문 곤충 (IOI22_insects)C++17
99.89 / 100
67 ms424 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(int N) { vector<int> types; vector<int> left; for (int i = 0; i < N; i++) { move_inside(i); if(press_button() > 1){ left.push_back(i); move_outside(i); } else{ types.push_back(i); } } if(types.size() >= N / 2 + 1) return 1; if(types.size() == 1) return N; int l = 2, r = N / types.size(); int ans = 1; int leftOutN = 0; while(l <= r){ vector<int> tmp; int mid = (l + r) / 2; for(int a:left){ move_inside(a); if(press_button() > mid){ move_outside(a); tmp.push_back(a); } } if(N - tmp.size() - leftOutN == mid * types.size()){ l = mid + 1; ans = mid; left = tmp; } else{ r = mid - 1; ans = mid - 1; vector<int> tmp1; for(int a:left){ if(find(tmp.begin(), tmp.end(), a) == tmp.end()){ move_outside(a); tmp1.push_back(a); } else{ ++leftOutN; } } left = tmp1; } } return ans; }

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

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:21:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |     if(types.size() >= N / 2 + 1) return 1;
      |        ~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...