Submission #100793

#TimeUsernameProblemLanguageResultExecution timeMemory
100793Bodo171The Big Prize (IOI17_prize)C++14
97.24 / 100
56 ms5976 KiB
#include "prize.h" #include <fstream> #include <vector> #include <iostream> #include <cmath> using namespace std; const int nmax=200005; const int prdf=500;//modifici dupa asta int lg[nmax]; int spec[nmax],norm[nmax],us[nmax]; int mx,nr,i,gasit; vector<int> v[nmax]; int cate_st(int poz) { if(v[poz].empty()) v[poz]=ask(poz); return v[poz][0]; } int cate(int poz) { if(v[poz].empty()) v[poz]=ask(poz); if(!(v[poz][0]+v[poz][1])) gasit=1; return (v[poz][0]+v[poz][1]); } int cate_dr(int poz) { return (cate(poz)-cate_st(poz)); } int n; void solve(int st,int dr) { if(st>dr) return; if(gasit) return; if(cate(st)!=cate(dr)) { if(cate(st)<cate(dr)) { if(!us[st])spec[++nr]=st,us[st]=1; solve(st+1,dr); return; } if(!us[dr])spec[++nr]=dr,us[dr]=1; solve(st,dr-1); return; } if(st==dr&&cate(st)<mx) { if(!us[st]) spec[++nr]=st,us[st]=1; } if(st+1>=dr) return; if(cate_st(st)+cate_dr(dr)==cate(st)) return; int m=(st+dr)/2; solve(st,m); solve(m,dr); } int find_best(int N) { n=N; for(i=0;i<min(prdf,n);i++) { v[i]=ask(i); if(v[i][0]+v[i][1]>mx) mx=v[i][0]+v[i][1]; } spec[0]=-1; for(i=0;i<min(prdf,n);i++) { if(v[i][0]+v[i][1]!=mx) { ++nr;norm[i]=nr;spec[nr]=i; if(!cate(i)) return i; } } solve(prdf,n-1); for(i=1;i<=mx;i++) if(cate(spec[i])==0) return spec[i]; return 0; }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:74:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(i=1;i<=mx;i++)
     ^~~
prize.cpp:77:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  return 0;
  ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...