Submission #289169

#TimeUsernameProblemLanguageResultExecution timeMemory
289169Bill_00The Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 KiB
#include <prize.h> #include <bits/stdc++.h> using namespace std; void search(int mid,int l,int r){ vector<int>res=ask(mid); if(res[0]+res[1]==0){ ans=mid; return; } if(l==r){ return; } if(res[1]==0){ search((mid-1+l)>>1,l,mid-1); } if(res[0]==0){ search(mid+1+r>>1,mid+1,r); } if(res[1]!=0 && res[0]!=0){ search((l+mid-1)/2,l,mid-1); search((mid+1+r)/2,mid+1,r); } } int find_best(int n){ m=n; /*for(int i = 0; i < n; i++) { std::vector<int> res = ask(i); if(res[0] + res[1] == 0) return i; }*/ int l=0,r=n-1; int mid=(l+r)>>1; search(mid,l,r); return ans; }

Compilation message (stderr)

prize.cpp: In function 'void search(int, int, int)':
prize.cpp:7:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
    7 |   ans=mid;
      |   ^~~
      |   abs
prize.cpp:17:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |   search(mid+1+r>>1,mid+1,r);
      |          ~~~~~^~
prize.cpp: In function 'int find_best(int)':
prize.cpp:25:2: error: 'm' was not declared in this scope
   25 |  m=n;
      |  ^
prize.cpp:34:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |  return ans;
      |         ^~~
      |         abs