제출 #975277

#제출 시각아이디문제언어결과실행 시간메모리
975277StefanSebezThe Big Prize (IOI17_prize)C++14
20 / 100
3 ms2136 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back mt19937 rng(time(0)); int nekict=0; int find_best(int n){ pair<int,int> temp[n+10]; for(int i=0;i<n;i++) temp[i].fi=temp[i].se=-1; int ct=150,V=n; while(ct--){ int x=rng()%n; vector<int>tmp; if(temp[x].fi==-1) {tmp=ask(x);nekict++;} else tmp.pb(temp[x].fi),tmp.pb(temp[x].se); temp[x]={tmp[0],tmp[1]}; if(n-(tmp[0]+tmp[1])<V) V=n-(tmp[0]+tmp[1]); } int res=-1; set<int>st; st.insert(-1),st.insert(n); auto it=st.begin(); int sajz=0; while(it!=st.end()){ if(nekict>=10000-10) break; auto it2=it; int i=*it; if(res!=-1 && res==i) break; it++; if(it==st.end()) break; int j=*it; if(i!=-1 && j!=n && temp[j].fi-temp[i].fi==0) continue; int l=i+1,r=j-1; //printf("%i %i %i\n",i,j,sajz); while(l<=r){ if(nekict>=10000-10) break; int mid=(l+r)/2; vector<int>tmp; if(temp[mid].fi==-1) {tmp=ask(mid);nekict++;} else tmp.pb(temp[mid].fi),tmp.pb(temp[mid].se); temp[mid]={tmp[0],tmp[1]}; if(n-tmp[0]-tmp[1]!=V){ if(tmp[0]==0 && tmp[1]==0) {res=mid;break;} st.insert(mid); r=mid-1; continue; } if(tmp[0]>=1+sajz) r=mid-1; else l=mid+1; } it=it2; it++; sajz++; } /*for(auto i=st.begin();i!=st.end();i++){ int x=*i; if(x==-1 || x==n) continue; if(temp[x].fi==0 && temp[x].se==0) res=x; }*/ //for(auto i=st.begin();i!=st.end();i++) printf("%i ",*i); //printf("\n"); /*for(int i = 0; i < n; i++) { std::vector<int> res = ask(i); if(res[0] + res[1] == 0) return i; }*/ return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...