제출 #642239

#제출 시각아이디문제언어결과실행 시간메모리
642239czhang2718드문 곤충 (IOI22_insects)C++17
0 / 100
6 ms256 KiB
#include "insects.h" #include "bits/stdc++.h" using namespace std; int min_cardinality(int n) { int ans=0; vector<int> v(n); iota(v.begin(), v.end(), 0); int d=0; for(int i=0; i<n; i++){ move_inside(i); int c=press_button(); if(c>1) move_outside(i); else d++; } if(d==1) return n; if(d==n) return 1; vector<bool> inside(n); for(int k=31-__builtin_clz(n/d); k>=0; k--){ if((ans+(1<<k))>n/d) continue; int cnt=0; for(int x:v) inside[x]=0; for(int i=0; i<v.size(); i++){ move_inside(v[i]); int c=press_button(); if(c>(1<<k)) move_outside(v[i]); else cnt++, inside[v[i]]=1; } vector<int> v2; if(cnt==(1<<k)*d){ for(int x:v){ if(!inside[x]) v2.push_back(x); } ans+=(1<<k); } else{ for(int x:v){ if(inside[x]) v2.push_back(x); } } swap(v,v2); } return ans; }

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

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:23:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0; i<v.size(); i++){
      |                  ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...