이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
#define endl "\n"
const int mxn=2e3+5;
int sz,n,cnt,color[mxn],color2[mxn];
set<int>ST;
bool check(int k){
set<int>st;
st=ST;
memset(color2,0,sizeof(color2));
for(int i=0;i<n;i++){
if(color[i]) continue;
move_inside(i);
st.insert(i);
if(press_button()>k){
st.erase(i);
color2[i]=1;
move_outside(i);
}
}
if(st.size()==cnt*k){
ST=st;
return 1;
}
else{
for(int i=0;i<n;i++){
if(color2[i]){
color[i]=1;
}
}
for(auto x:st){
move_outside(x);
}
ST.clear();
return 0;
}
}
int min_cardinality(int N) {
n=N;
set<int>st;
for(int i=0;i<n;i++){
move_inside(i);
cnt++;
st.insert(i);
if(press_button()>1){
move_outside(i);
st.erase(i);
cnt--;
}
}
for(auto x:st){
move_outside(x);
}
if(cnt==1) return n;
if(cnt==n) return 1;
int l=1,r=n/cnt;
while(l<=r){
int m=(l+r)/2;
if(check(m)){
l=m+1;
}
else{
r=m-1;
}
}
return l-1;
}
컴파일 시 표준 에러 (stderr) 메시지
insects.cpp: In function 'bool check(int)':
insects.cpp:33:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
33 | if(st.size()==cnt*k){
| ~~~~~~~~~^~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |