제출 #1078247

#제출 시각아이디문제언어결과실행 시간메모리
1078247Faisal_Saqib드문 곤충 (IOI22_insects)C++17
99.95 / 100
49 ms980 KiB
#include <bits/stdc++.h> using namespace std; void move_inside(int i); void move_outside(int i); int press_button(); int min_cardinality(int n) { set<int> machine,rem; machine.insert(0); move_inside(0); for(int i=1;i<n;i++) { move_inside(i); if(press_button()==1) { machine.insert(i); } else { rem.insert(i); move_outside(i); } } int sz=machine.size(); int s=1; int e=(n/sz)+1; while(s+1<e) { int mid=(s+e)/2; vector<int> cur; for(auto i:rem) { if(machine.size()==(sz*mid)) break; move_inside(i); if(press_button()>mid) { move_outside(i); } else { cur.push_back(i); machine.insert(i); if(machine.size()==(sz*mid)) break; } } if(machine.size()==((sz*mid))) { s=mid; for(auto&i:cur) rem.erase(i); } else{ e=mid; rem.clear(); for(auto&i:cur) { rem.insert(i); machine.erase(i); move_outside(i); } } } return s; }

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

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:33:21: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |    if(machine.size()==(sz*mid))
      |       ~~~~~~~~~~~~~~^~~~~~~~~~
insects.cpp:44:22: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     if(machine.size()==(sz*mid))
      |        ~~~~~~~~~~~~~~^~~~~~~~~~
insects.cpp:48:20: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |   if(machine.size()==((sz*mid)))
      |      ~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...