This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "prize.h"
#include <vector>
using namespace std;
int search(int l, int r) {
if (l > r) return -1;
if (l == r) {
vector<int> ans = ask(l);
if (ans[0] == 0 && ans[1] == 0) return l;
return -1;
}
int m = (l+r)/2;
vector<int> ans = ask(m);
if (ans[0] == 0 && ans[1] == 0) return m;
if (ans[0] == 0) {
return search(m+1, r);
}
else if (ans[1] == 0) {
return search(l, m-1);
}
else {
int ans1, ans2;
ans1 = search(l, m-1);
ans2 = search(m+1, r);
return (ans1 == -1 ? ans2 : ans1);
}
return -1;
}
int find_best(int n) {
return search(0, n-1);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |