제출 #630997

#제출 시각아이디문제언어결과실행 시간메모리
630997garam1732드문 곤충 (IOI22_insects)C++17
73.05 / 100
137 ms568 KiB
#include "insects.h" #include <iostream> #include <vector> #include <stack> #include <set> #include <algorithm> #define ff first #define ss second using namespace std; typedef pair<int, int> pi; //vector<int> ans; //stack<pi> S, v; vector<int> v, w; set<int> s; int min_cardinality(int N) { int num = 0; for(int i = 0; i < N; i++) { move_inside(i); num++; if(press_button() > 1) { move_outside(i); num--; s.insert(i); } } int sum = num; int lb = 1, ub = N, mid; while(lb < ub) { mid = (lb*2+ub+2)/3; for(int i : s) { move_inside(i); if(press_button() > mid) { move_outside(i); v.push_back(i); } else w.push_back(i); } if(w.size()+sum == mid*num) { lb = mid; for(int t : w) s.erase(t); sum += w.size(); } else { ub = mid-1; for(int t : v) s.erase(t); for(int t : w) move_outside(t); } v.clear(); w.clear(); } return lb; }

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

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