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 <bits/stdc++.h>
#include "prize.h"
using namespace std;
const int N = 2e5 + 5;
int a[N];
int b[N];
int s[N];
int ans;
vector <int> v;
/*vector<int> ask(int i) {
cout << i << '\n';
vector<int> res(2);
cin >> res[0] >> res[1];
return res;
}
*/
void divide(int st, int dr)
{
int mid = (st + dr) / 2;
if (s[mid])
return;
v = ask(mid);
a[mid] = v[0];
b[mid] = v[1];
s[mid] = a[mid] + b[mid];
if (s[mid] == 0)
{
ans = mid;
return;
}
if (ans)
return;
if (!(s[st] == s[mid] && a[mid] == a[st]))
divide(st, mid);
if (ans)
return;
if (!(s[dr] == s[mid] && a[mid] == a[dr]))
divide(mid, dr);
return;
}
int find_best(int n)
{
vector <int> v;
v = ask(0);
a[0] = v[0];
b[0] = v[1];
s[0] = a[0] + b[0];
v = ask(n - 1);
a[n - 1] = v[0];
b[n - 1] = v[1];
s[n - 1] = a[n - 1] + b[n - 1];
if (s[0] == 0)
ans = 0;
if (s[n - 1] == 0)
ans = n - 1;
divide(0, n - 1);
cout << ans;
return ans;
}/*
int main()
{
find_best(8);
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |