Submission #415142

#TimeUsernameProblemLanguageResultExecution timeMemory
415142Bill_00The Big Prize (IOI17_prize)C++14
97.61 / 100
87 ms1952 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; int l[200005],r[200005],x[200005],answer=-1; void solve(int L,int R){ if(answer!=-1) return; if(L+1==R){ return; } int m=(L+R)>>1; vector<int>res=ask(m); l[m]=res[0]; r[m]=res[1]; if(l[m]+r[m]==0){ answer=m; return; } if(l[m]!=l[R] || r[m]!=r[R]){ solve(m,R); } if(answer!=-1) return; if(l[m]!=l[L] || r[m]!=r[L]){ solve(L,m); } } int find_best(int n){ // for(int i = 0; i < n; i++){ // std::vector<int> res = ask(i); // if(res[0] + res[1] == 0) // return i; // } for(int i=0;i<n;i++){ l[i]=r[i]=-1; } int m=(n-1)/2; vector<int>res=ask(0); l[0]=res[0]; r[0]=res[1]; if(l[0]+r[0]==0) return 0; res=ask(n-1); l[n-1]=res[0]; r[n-1]=res[1]; if(l[n-1]+r[n-1]==0) return n-1; solve(0,n-1); return answer; }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:35:6: warning: unused variable 'm' [-Wunused-variable]
   35 |  int m=(n-1)/2;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...