Submission #245486

#TimeUsernameProblemLanguageResultExecution timeMemory
245486LittleFlowers__The Big Prize (IOI17_prize)C++17
20 / 100
122 ms6044 KiB
#include <bits/stdc++.h> using namespace std; //#define in ({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';n?-x:x;}) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r){return l+rng()%(r-l+1);} #define fasty ios_base::sync_with_stdio(0),cin.tie(0); #define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a) #define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a) #define forv(a,b) for(auto&a:b) #define fi first #define se second #define pb push_back #define ii pair<int,int> #define mt make_tuple #define all(a) a.begin(),a.end() #define reset(f, x) memset(f, x, sizeof(f)) #define gg exit(0); #include "prize.h" const int N=200010; int asked[N]; vector<int> f[N]; vector<int> qry(int i){ if(asked[i]) return f[i]; asked[i]=1; return f[i]=ask(i-1); } int small=-1; int same(int i,int j){ auto x=qry(j); return x[0]+x[1]==small; } int cnt(int i,int j){ if(i>j) swap(i,j); auto x=qry(i), y=qry(j); return y[0]-x[0]-(x[0]+x[1]>y[0]+y[1]); } int asking[]={516,159997,78157,20234,139735,97773,123810,116521,55707,149210,134149,116330,33024,159877,142685,131916,12987,180395,128374,61148,113019,86285,38403,85981,132497,183478,9811,108433,158080,107465,29344,190346,18746,140511,80220,101975,174685,2645,74842,139652,68464,178017,108767,151912,92797,12364,142335,71014,165504,77369,115018,53368,197303,65410,6242,13645,24507,192963,199280,190488,133888,68682,139403,157306,99484,11400,197835,148732,86181,193546,110956,98396,87726,188090,45340,12305,35773,135458,90006,28850,120431,182164,44685,145338,137917,119750,99544,79065,164450,78171,22952,68788,197392,184954,153503,24325,139638,67687,64118,189294,71443,117400,180347,74367,77630,20471,100343,124716,91601,94177,117310,186130,16848,11133,107811,62791,92326,82387,175383,13449,118491,88026,108905,165581,120826,86242,120852,163284,167531,196496,123784,112545,142614,3571,140805,109434,5246,168627,28754,96339,150156,114746,47778,145587,70605,7320,15869,31365,171521,141703,122681,70468,195698,65133,147179,109013,77223,105722,139443,39583,178023,89098,138447,158607,158716,188761,37425,47689,27582,160446,43333,152594,160282,167497,87743,71857,18221,193586,34571,144363,184200,188153,154972,152553,57944,47849,85308,56966,9734,66068,171206,95194,167705,187533,62181,147628,60251,181576,182565,148315}; int find_best(int n){ int l=1,tmp=-1; forinc(t,1,200){ int j=t>1 ? n==2e5 ? asking[t-1] : rnd(1,n) : 1; auto a=qry(j); if(a[0]+a[1]==0) return j-1; if(tmp<a[0]+a[1]) tmp=a[0]+a[1]; } small=tmp; int i=l, sz=0; vector<int> val; vector<int> lf(555),rt(555); forinc(i,0,500){ lf[i]=1; rt[i]=n; } int cur=0; while(i<n){ int le=max(i+1,lf[cur]),mi,ri=rt[cur]; cur++; while(le<=ri){ mi=(le+ri)/2; if(same(l,mi)){ forinc(j,cnt(l,mi),500) lf[j]=max(lf[j],mi); forinc(j,cur,cnt(l,mi)-1) rt[j]=min(rt[j],mi); } if(same(l,mi) && cnt(l,mi)==sz) i=mi,le=mi+1; else ri=mi-1; } if(i==n) break; auto a=qry(++i); if(a[0]+a[1]==0) return i-1; sz++; } }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:80:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...