제출 #723421

#제출 시각아이디문제언어결과실행 시간메모리
723421LittleFlowers__드문 곤충 (IOI22_insects)C++17
25 / 100
391 ms316 KiB
#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)); int ma=n; 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)); mx=min(mx,ma); forv(j,a) if(!dd[j]) { move_inside(j); int press=press_button(); if(press>mx) { move_outside(j); } else { b.pb(j); ma=press; } } int szb=b.size(); if(szb%ma) --ma; swap(a,b); b.clear(); forv(j,a) move_outside(j); //cout<<"sz"<<" "<<a.size()<<endl; } } /*int main() { cout<<min_cardinality(5); }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...