Submission #245336

#TimeUsernameProblemLanguageResultExecution timeMemory
245336LittleFlowers__The Big Prize (IOI17_prize)C++17
0 / 100
12 ms504 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()); mt19937 rng(1012); 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; vector<int> qry(int i){ return ask(i-1); } int same(int i,int j){ auto x=qry(i), y=qry(j); return x[0]+x[1]==y[0]+y[1]; } int cnt(int i,int j){ if(i>j) swap(i,j); auto x=qry(i), y=qry(j); return y[0]-x[0]; } int find_best(int n){ int l,tmp=-1; forinc(j,1,500){ auto a=qry(j); if(a[0]+a[1]==0) return j; if(tmp<a[0]+a[1]){ tmp=a[0]+a[1]; l=j; } } int i=l, sz=0; vector<int> val; while(i<n){ int le=i+1,mi,ri=n; while(le<=ri){ mi=(le+ri)/2; 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:63:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
prize.cpp:53:13: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
         int le=i+1,mi,ri=n;
             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...