제출 #1077745

#제출 시각아이디문제언어결과실행 시간메모리
1077745pcc드문 곤충 (IOI22_insects)C++17
54.05 / 100
112 ms1104 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; const int mxn = 2022; vector<int> v[mxn]; set<int> st; int N; int cnt = 0; const int B = 5; void del(int k){ assert(st.find(k) != st.end()); st.erase(k); move_outside(k); return; } void add(int k){ assert(st.find(k) == st.end()); st.insert(k); move_inside(k); return; } int ask(){ int re = press_button(); return re; } bool check(int lim){ for(int i = lim+1;i<=N;i++){ while(!v[i].empty()){ auto now = v[i].back(); v[i].pop_back(); del(now); } } for(int i = 0;i<N;i++){ if(st.find(i) == st.end()){ add(i); int re = ask(); if(re>lim)del(i); else v[re].push_back(i); } } return lim*cnt == st.size(); } int min_cardinality(int NN) { N = NN; check(1); cnt = st.size(); if(N/cnt<=B){ for(int i = 2;i<=N/cnt;i++){ if(!check(i))return i-1; } return N/cnt; assert(false); } int l = 1,r = N/cnt; while(l != r){ int mid = (l+r+1)>>1; if(check(mid))l = mid; else r = mid-1; } return l; }

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

insects.cpp: In function 'bool check(int)':
insects.cpp:47:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |  return lim*cnt == st.size();
      |         ~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...