이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "insects.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int hmt() {int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';if(n) x=-x;return x;}
#define in hmt()
#define ins ({string x;char c=getchar();for(;c==' '||c=='\n';c=getchar());for(;c!=' '&&c!='\n';c=getchar()) x+=c;x;})
#define forinc(i,a,b) for(int i=a,_b=b;i<=_b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forb(i,BS) for(int i=BS._Find_first();i< BS.size();i = BS._Find_next(i))
#define timer 1.0*clock()/CLOCKS_PER_SEC
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
int n,dd[2010];
vector<int> a,b;
/*void move_inside(int i) {cout<<"i "<<i<<endl;}
void move_outside(int i) {cout<<"o "<<i<<endl;}
int press_button() {cout<<"g\n";int x;cin>>x;return x;}*/
int min_cardinality(int N) {
n=N;
forinc(i,0,n-1) a.pb(i);
random_shuffle(all(a));
while(1) {
reset(dd,0);
int sz=a.size();
int i=a[rand()%sz];
move_inside(i);
dd[i]=1;
int mx=1;
forv(j,a) if(!dd[j]) {
move_inside(j);
if(press_button()>mx) {
++mx;
dd[j]=1;
} else move_outside(j);
}
if(mx==sz||mx==1) return mx;
forv(j,a) if(dd[j]) move_outside(j);
random_shuffle(all(a));
//if(sz%mx) --mx;
forv(j,a) if(!dd[j]) {
move_inside(j);
int press=press_button();
if(press>mx) {
move_outside(j);
} else b.pb(j);
}
swap(a,b);
b.clear();
forv(j,a) move_outside(j);
//cout<<"sz"<<" "<<a.size()<<endl;
}
}
/*int main() {
cout<<min_cardinality(5);
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |